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

Create an encapsulated "Dust template" class #516

Open
sethkinast opened this issue Oct 30, 2014 · 6 comments
Open

Create an encapsulated "Dust template" class #516

sethkinast opened this issue Oct 30, 2014 · 6 comments

Comments

@sethkinast
Copy link
Contributor

Dust templates currently compile to a set of functions that are invoked via body_0 being registered by dust.register.

In #513 we suggest that these body functions could be members of a "Body" class so that we don't have to set magic flags on them to distinguish them from regular functions. In addition, .render() methods could be part of the class instead of invoking the function directly, etc.

@rragan
Copy link
Contributor

rragan commented Oct 30, 2014

It sure would be nice to make a way to compile a template to a CommonJS format so just require(xxx.dust) would work

@sethkinast
Copy link
Contributor Author

I agree-- what form would the required object take? Would it have a .render() method on it, or do you require templates and then pass them to Dust?

@pixshatterer
Copy link

why not follow the proposal already in #330? seems like the pull request was blocked due to conflicts, but it looks like a good implementation

@semanio
Copy link

semanio commented Dec 6, 2014

Agreed with @pixshatterer that #330 seems to be doing the same thing.

@sethkinast
Copy link
Contributor Author

This is actually not about treating templates as modules. It's the need to
not attach properties directly to the magic dust functions that themselves
only function if dust is a global.

330 is not related but it's still no less nice to have.
On Dec 5, 2014 6:15 PM, "Nate Hanna" notifications@github.com wrote:

Agreed with @pixshatterer https://github.com/pixshatterer that #330
#330 seems to be doing the same
thing.


Reply to this email directly or view it on GitHub
#516 (comment).

@jjclark1982
Copy link

#330 is related because when you require() a dust file, you want the result to be an instance of a standard Dust template class, with standard methods such as .render().

In order to make a require handler that did not depend on subsequently calling the dust global, I had to attach ad-hoc render and stream methods alongside the existing magic properties. It would be better to use a standard class with standard methods.

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

No branches or pull requests

5 participants