-
Notifications
You must be signed in to change notification settings - Fork 513
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
Add support of extend and block in EJS #142
Conversation
add features of extend and block, could support multilayer inheritance, could fully support the layout in EJS. Also could work with include. The examples and test has also been add!
the test in benchmark shows that the layout using extend is 33% faster than that using include
+1 |
How to use the extend and block feature? |
Oh, I found it. |
@welkang, yes, that is the way. You could also refer to the examples in the source code. Have fun |
+1 |
|
||
|
||
//the extend symbol must be in the first place of the file if exist | ||
if(str.trim().indexOf(open + "+") == "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.
the rest looks fine and the tests are good but we'd definitely want to try and make this chunk more declarative it's not super obvious and it's a lot to cram into the one function
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.
yes, you are right. I used too many temp variables in the function. I'll spend my weekend to optimize the code, make it more declarative. we can talt about it later.
The extend feature is very useful and necessary. So I advise strongly that it could be merged into the trunk sooner or later. thanks!
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.
there's also #147 which is similar, it would be great if you could maybe check out that PR and help review :D at a glance they both look really similar
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.
ok, I'd like to :D
reorganize the code related to extend , make it more declarative
I am excited about this feature returning to EJS, but I'd like to point out that 'extend' and 'layout' are really two different features. With 'layout', you are requesting that the entire content of the current view be wrapped in a particular view. With 'extend', you are instead defining certain blocks that will override the corresponding blocks in the extended view. While possible to do with both, generally extended views can stack many generations deep, while layouts typically don't. While I would love to see both features in EJS, I think it's important to recognize the commonalities and differences between them. Both this and #147 seem to be describing 'extend', but #147 refers to it as 'layout'. Also, while I'm here, I may as well mention a feature with 'extend' that I've seen (and love) in other template engines: the ability to supplement content in a block, either by explicitly defining 'prepend' or 'append' in the tag or by defining a sub-tag within the block that defines where the ancestor's content should live. |
yes, I agree that extend and layout are two different features. And in practice, |
@AdamPuzio You're right, #147 is describing "extend" as well. My use of the term I don't see the I like the idea of prepend/append, and @ictliujie notion of using Filters seems promising. I'll give it some thought for #147. @visionmedia Is this something you would want in an initial launch of templates? |
Any news on this? |
+1 @visionmedia plans to merge this? |
+1 |
3 similar comments
+1 |
+1 |
+1 |
@visionmedia It's been a while since EJS has received any development attention. Are you going to allow people to start taking over this project or is EJS dying? |
Hey guys. I found the extend and block feature I wanted here: https://github.com/RandomEtc/ejs-locals |
@freeauto is the also a block append / prepend feature? |
@ilanbiala I see many pull request waiting for months. I'm going to find another template node module, EJS is clearly not good enough, there is not even what are the basics for me, coming from Ruby I have the feeling that I can't work with EJS. |
@Vadorequest, I am the new maintainer of this module, and I hope to get things moving a bit faster once I've familiarized myself more with the codebase. I am also the maintainer of the Geddy Web app framework for Node (http://geddyjs.org/), which has its own bundled EJS implementation (https://github.com/geddy/geddy/blob/master/lib/template/engines/ejs.js) that also has a couple of features missing here. I hope you'll be patient and give me a chance to ramp up. As far as "being from the Ruby world," EJS is almost precisely the same as ERB, which was the default in Rails for years. (I haven't followed to see if they've switched to HAML recently or not.) |
@mde Nice! Do you have any idea about what you will start to add/fix in EJS? |
+1 |
Very interested in this particular functionality. +1 Just to add to the discussion https://github.com/gett/pejs does some of this as well. |
@Vadorequest @mde nothing's moved since May 1st, when TJ made the last commit. I've pretty much moved away from EJS, and there are plenty of other template engines out there. |
Yeah... I keep an eye on it but I don't have much faith in EJS I have to |
what is the progress on this? |
guys, here is my block implementation for the new ejs. |
Is anything happening with this? |
Has this support been added ? |
This version of EJS is no longer maintained. The current version, installable via NPM, is here: https://github.com/mde/ejs |
@visionmedia, fyi:
Add features of extend and block, which could support
(1) multilayer inheritance, fully support layout in EJS.
(2) Also could work with include.
The examples and test has also been add!