Add basic support for Eco templates #12

merged 5 commits into from May 18, 2012


None yet

2 participants


This adds support for the text/x-eco mimetype, which will be processed using eco (

It supports specifying an attribute in the script tag named data-eco-root which tweaks the namespace to which the compiled template functions will be assigned.

Known limitations

One minor thing still on which I'd still like to improve at a later point is how the name of the template function is determined. Right now this is left to the eco compiler, which just uses the file's basename. This would cause problems in case we have two templates like templates/user/ and templates/airplane/ Ideally I'd have a way to specify that one is user/detail and the other airplane/detail. But this can come at a later stage.

pilif commented May 18, 2012

very cool. Thanks.

Can you update NEWS aswell, please?

brainlock added some commits May 18, 2012
@brainlock brainlock add basic eco templates support
This adds support for Eco (
client-side templates, under the mimetype 'text/x-eco'.

Define SACY_TRANSFORMER_ECO to point to the eco executable.
@brainlock brainlock parse tag attributes that contain dashes
The regex is wrong, it will also match attr names like `a-` or `-b?` or
even `-`, which are of course not valid.

Since the whole concept of sacy is centered around parsing
developer-supplied html and doesn't use a full-blown parser, I feel
the compromise is acceptable here in order to keep the regex simple.
@brainlock brainlock parse data attributes
This puts the html data attributes under the key `data` in the work unit

For example, for the following script tag:

<script data-some-option="blah" data-other-options="blih" ...

The work unit array will contain:

  'data' => array(
      'some-option' => 'blah',
      'other-option' => 'blih'
@brainlock brainlock ExternalProcessor: allow passing options down to getCommandLine()
An optional third argument to ->transform() will be passed down to
@brainlock brainlock eco transformer: allow specifying the template root
Use data-eco-root="XYZ" in the script tag to have the template
assigned to window.XYZ instead of the default JST.

Sure, there you go. I rebased the branch.

@pilif pilif merged commit e823d70 into pilif:master May 18, 2012
pilif commented May 18, 2012

thanks a lot merymerge

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