Allow to extend mustache #109

jcubic opened this Issue Sep 13, 2012 · 0 comments


None yet
1 participant

jcubic commented Sep 13, 2012

Maybe it's good idea to allow extension of mustache wihout modifing library or Mustache class so user can put {{@foo}} or {{%foo}} and those will execute user defined function

$mustache = Mustache_Engine(array(
    'modifiers' => array(
       '%' => function($tag) {
            return file_get_contents($tag);


$mustache = Mustache_Engine(array(
    'tags_extension' => function($modifier, $tag_name, $leading, $trailing) {
        switch($modifier) {
            case '%':  return file_get_contents($tag_name);

and user will be able to put

      <h1>My robots.txt</h1>

and those modifiers will be check in _renderTag method after all of tags or before so they can be overwriten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment