Friday 15 August 2014

javascript - What is the difference between an include, a partial, and/or a block in templating. EJS / ejs-locals -


I have some time to express and node I am experimenting with JS and I think I understand the basics. I have experimented with the ejs included function, which allowed me to include a template inside another. I have also used a library, which provides easy true layout support. One thing I have noticed is that ejs-localals also define partial and blocks functions which can be used with EJS. I can not get a better explanation about the differences between these three concepts, as far as I can tell that they are generally general concepts for templating and not only EJS, I think both of partial and blocks are still the way to include other template files, but how are they different?

include : takes content from the given file and returns it Where your is included statement is in other words: The file has access to all the variables defined in that file, in which it is included.

partial : include , with the difference that only partial access to those variables that you have passed near while rendering.

Block : In your layout, you define the locations where the contents of your block should be. In the file you have submitted, you define the content for these blocks and define the layout that you want to present your block content to.

No comments:

Post a Comment