Skip to content

Commit

Permalink
Add jsRequirements and cssRequirements to mustache helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
mducharme committed Feb 22, 2016
1 parent 814790a commit 2dd7a59
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Charcoal/View/Mustache/GenericHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function getIterator()
'addJsRequirement' => function($jsRequirement) {
return $this->addJsRequirement($jsRequirement);
},
'jsRequirements' => function() {
return $this->jsRequirements();
},
'addCss' => function($css, Mustache_LambdaHelper $helper) {
return $this->addCss($css, $helper);
},
Expand Down Expand Up @@ -100,6 +103,18 @@ public function addJsRequirement($jsRequirement)
}
}

/**
* Ouput and reset JS requirements
*
* @return string
*/
public function jsRequirements()
{
$req = implode("\n", self::$jsRequirements);
self::$jsRequirements = [];
return $req;
}

/**
* @param string $css
* @return void
Expand Down Expand Up @@ -134,4 +149,16 @@ public function addCssRequirement($cssRequirement)
self::$cssRequirements[] = $cssRequirement;
}
}

/**
* Ouput and reset CSS requirements
*
* @return string
*/
public function cssRequirements()
{
$req = implode("\n", self::$cssRequirements);
self::$cssRequirements = [];
return $req;
}
}

0 comments on commit 2dd7a59

Please sign in to comment.