-
Notifications
You must be signed in to change notification settings - Fork 7
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
Keep reference to this
#3
Conversation
@@ -46,7 +46,7 @@ function addWith(obj, src, exclude) { | |||
|
|||
src = '(function (' + vars.join(', ') + ') {' + | |||
src + | |||
'}(' + inputVars.join(',') + '))' | |||
'}.bind(this)(' + inputVars.join(',') + '))' |
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 we fix this to use .call(this, ...args)
rather than .bind(this)(...args)
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.
Sure!
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.
Stop!!! Then you should change AST checking too! otherwise it will fail.
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.
Oh I see, you've changed AST checking too -)
Sorry, I'm thinking at lower speed than you probably
FYI, I like the idea of making mixins first class values that can be passed around until they are used. I'm not entirely clear on the relevance of |
As for this pull request, there is no question about it, |
Hi! Thank you for the reply! I'm working on the text for the detailed
|
I've merged this manually, with a small modification. Thanks for the contribution! |
Hi. I'm working on semi-conservative refactoring of mixins in jade (all existing unit tests are passed, only private api slightly changed) to make them first class objects, as well as proper handling of
this
refernece in templates. In classical jadethis
reference is used for passing of {block,attributes} to the mixin likeI've refactored lexer/parser/compiler + with
to make mixins essentialy a curried functions while decoupling them from jade-runtime and buf:
so now mixins can be compiled separately with
jade.compileMethod(src, options)
and passed as parameters for templates, or attached to function prototype to make templates as methods, or simply bound bymixin.bind(someobj)
also i've added first-class mixin call syntax
All this features are based on small enhancement of
with
module to make it respectful forthis
reference.My semantics/syntax for mixins is arguable but I hope that at least this change in
with
matters and can be merged.Regards, Anatoly
P.S. my fork of jade is here https://github.com/Artazor/jade - it would be great to hear any comments about that direction