Add basic support for Eco templates #12

Merged
merged 5 commits into from May 18, 2012

Projects

None yet

2 participants

@brainlock

This adds support for the text/x-eco mimetype, which will be processed using eco (https://github.com/sstephenson/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/detail.eco and templates/airplane/detail.eco. 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
Owner
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 (https://github.com/sstephenson/eco)
client-side templates, under the mimetype 'text/x-eco'.

Define SACY_TRANSFORMER_ECO to point to the eco executable.
e6adb1f
@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.
9127015
@brainlock brainlock parse data attributes
This puts the html data attributes under the key `data` in the work unit
description.

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'
  )
455a217
@brainlock brainlock ExternalProcessor: allow passing options down to getCommandLine()
An optional third argument to ->transform() will be passed down to
getCommandLine().
25a84ae
@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.
847cd8b
@brainlock

Sure, there you go. I rebased the branch.

@pilif pilif merged commit e823d70 into pilif:master May 18, 2012
@pilif
Owner
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