Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow to extend mustache #109

Open
jcubic opened this Issue · 0 comments

1 participant

@jcubic

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);
       }
    )
));

or

$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

<html>
   <body>
      <h1>My robots.txt</h1>
      <pre>{{%robots.txt}}</pre>
   </body>
</html>

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
Something went wrong with that request. Please try again.