ejs icon indicating copy to clipboard operation
ejs copied to clipboard

Added support extends, block, and include.

Open oldcookie opened this issue 11 years ago • 13 comments

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...

oldcookie avatar Jul 19 '12 04:07 oldcookie

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 time extend is probably going to be the first statement in a file. Let me know what you think.

oldcookie avatar Jul 19 '12 15:07 oldcookie

i like the intent here but it might take me a while to review since you rewrote a pretty large portion of it

tj avatar Jul 19 '12 16:07 tj

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.

oldcookie avatar Jul 19 '12 22:07 oldcookie

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

tj avatar Jul 19 '12 22:07 tj

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.

oldcookie avatar Jul 20 '12 02:07 oldcookie

Can't wait to see this gets merged

aziz avatar Aug 27 '12 15:08 aziz

I also am waiting for blocks and extend -- will be nice for scripts and stylesheets.

ralyodio avatar Sep 21 '12 06:09 ralyodio

+1 Been using QEJS in the meantime...

jeromegn avatar Oct 01 '12 16:10 jeromegn

+1

drefined avatar Nov 02 '12 20:11 drefined

+1

asabhaney avatar Feb 28 '13 21:02 asabhaney

+1

sballesteros avatar Mar 12 '13 03:03 sballesteros

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

dgbeck avatar Apr 12 '13 23:04 dgbeck

+1

azimonti avatar Apr 16 '13 01:04 azimonti