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

precompiled mixins & just-in-time mixins #10

Open
jeromew opened this issue Aug 1, 2014 · 0 comments
Open

precompiled mixins & just-in-time mixins #10

jeromew opened this issue Aug 1, 2014 · 0 comments

Comments

@jeromew
Copy link
Contributor

jeromew commented Aug 1, 2014

With commit c4950ea I added the capability to share a jade_mixins store between renderings.

if locals.jade_mixins is an object when a rendering is done, then this object will be filled with all the mixin functions that were found and compiled in the template (this is an upsert mechanism)

The rendering of another template with the same locals.jade_mixins object will be able to reuse those mixins via the dynamic mixins notation +#{name}(...)

With this commit, nothing is done to make sure that the shared mixin will use the same bufas a new rendering. In effect, they DO NOT have the same bufso a trivial setup will not work.

At this stage, the recommended way to make sure that a shared mixin is effectively rendered where it should be is to make sure that the mixins begin with the prototype (jade, buf, ..) and are called with those 2 vars :

// - template1.jade
mixin myMixin(jade, buf, message)
  h2= message

// - template2.jade
+#{"myMixin"}(jade, buf, "hello world");

This feature not only enables mixin sharing, but can also be used for just-in-time mixin compilation since a mixin yields and can take care of the mixin compilation asynchronously.

@ForbesLindesay I moved the discussion we started on jade here. Any toughts are welcome !

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

1 participant