ejs
ejs copied to clipboard
Added support extends, block, and include.
Layouts is supported using extends and blocks. To reduce repetition, blocks can have defaults. See Readme.md for details.
Include is also implemented to support mixins.
Finally, in order to support blocks with defaults, I ended rewriting the parser... hope that's ok...
Couple of things:
-
Blocks - Right now blocks need an
end
statement to demarcate the end of the block. So every time a block is defined or referenced, one need to put in the following, even if the block was empty.<% block foo %> ... <% end %>
While I am ok with that, I can see some people getting a bit annoyed with this. One alternative I thought about, was to use a do
end
pair like:
<% block someblock do %>
<% end %>
so that block only starts if do
is specified. block
without do
would be treated as empty blocks.
- Currently, only blocks that appears after an
extend
are treated as an argument. Not sure if that's right or wrong, since most of the timeextend
is probably going to be the first statement in a file. Let me know what you think.
i like the intent here but it might take me a while to review since you rewrote a pretty large portion of it
Sorry about that, tried to stick to the original, but supporting default blocks with the original parser was a bit tough. So I ended up making more chagea than I anticipated.
yeah understandable, we should have created an AST like Jade but the scope of EJS kinda changed with these features. im implementing includes right now the way that I would do them at least then we can add blocks in after
Well, there's is sort of an AST in what I've put in, creating a proper AST using that code wouldn't require a lot of changes.
Can't wait to see this gets merged
I also am waiting for blocks and extend -- will be nice for scripts and stylesheets.
+1 Been using QEJS in the meantime...
+1
+1
+1
what is the hold up I wonder? such a useful feature, love the ejs syntax but lack of blocks is a big down side. thx for all the great work on this project
+1
+1