Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for partials? #3

Closed
zanona opened this issue May 15, 2011 · 1 comment
Closed

Support for partials? #3

zanona opened this issue May 15, 2011 · 1 comment

Comments

@zanona
Copy link

zanona commented May 15, 2011

Hello, first of all congratulations for the excellent work and lightning fast engine:

One thing I've being trying is to port the concept of partials, like in mustache {{> partial_name}}, but it seems that it doesn't interpolates the result.

var data  = {
    name: 'John', 
    details : {age : 27},
    partial : "<p>Hello again {{= it.name}}</p>"
};

doT.template('Hello {{=it.name}}, you are {{=it.details.age}} years old! {{= it.partial }}')(data)

//outputs...
// Hello John, you are 27 years old!
// Hello again {{= it.name}}

As you can see the partial is not interpolated, so I was wondering if its possible to have this using doT?

perhaps something like mustache or handlebarsjs where I can do the following:

dot.template('...')({data: {...}, partials : {...}})

Thanks again :)

@olado
Copy link
Owner

olado commented May 23, 2011

Thanks! Compile-time evaluation with {{#defs.xxx}} could be used for this, but it was limited... until today :)
Today, I pushed changes to compile-time evaluation so that it works much better for cases like this and it also allows to define reusable snippets right in the template that could be used in the same template or included templates.
Please take a look at examples/advancedsnippet.txt for an example.
Is this what you were looking for?

@olado olado closed this as completed May 25, 2011
@ghost ghost mentioned this issue Jul 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants