-
Notifications
You must be signed in to change notification settings - Fork 479
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
Don't instaevaluate generated body_ functions. #513
Conversation
@@ -181,7 +181,7 @@ | |||
|
|||
for (i=0, len=bodies.length; i<len; i++) { | |||
out[i] = 'function body_' + i + '(chk,ctx){' + | |||
blx + 'return chk' + bodies[i] + ';}'; | |||
blx + 'return chk' + bodies[i] + ';}body_' + i + '.internal=true;'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use to (pre 2.4) have an isFunction check... perhaps it never worked as intended.... Anyways, this is much nicer since it's on the compiled object and not in the run time ctx object.
Now that we're in compile time, is it possible (perhaps overkill, might make it slower) to make body functions smarter. Instead of named functions can these be instances of a Bodies
class. I was never a fan of how block
was implemented, the strange relationship with elem
and never liked the fragile calls to body(chk,ctx)
. This is a pretty big change but some benefits: the implementation stays in dust and not in the compiler (DRYer no need to repeat .internal
), more extensible if we need to add additional properties, calls to body will be replace with body.render()
which will always to defined , potentially allows some cleanup to distinguish elem, block, body_0 etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment makes sense, I think we should open an feature issue on it. I can see how it could make things a lot less fragile, especially because I'm basically poor-man's-classing these functions already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
see comment above but 👍 since this address the issue cleanly |
8f917c5
to
d0efda4
Compare
@@ -181,7 +181,7 @@ | |||
|
|||
for (i=0, len=bodies.length; i<len; i++) { | |||
out[i] = 'function body_' + i + '(chk,ctx){' + | |||
blx + 'return chk' + bodies[i] + ';}'; | |||
blx + 'return chk' + bodies[i] + ';}body_' + i + '.__dust=!0;'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this .__dustBody
…to the context and attempt to render their containing block. Closes linkedin#512.
d0efda4
to
31309dc
Compare
Treat compiled body functions as blocks to render instead of functions to evaluate. Dust body functions are now flagged with .___dustBody to differentiate them from functions set in the context.
Instead, place them into the context and attempt to render their containing block.
Closes #512.