Comments (15)
I may not understand you correctly, but doesn't doT already allow this? Check http://olado.github.io/doT/index.html and then the tab 'partials'. Or do you mean the inclusion of actual template files?
from dot-view.
Oops, didn't mean to close this, wrong button.
from dot-view.
I don't think so? Right now to create a layout for a template you have to use
view.layout(new View('/layouts', 'layout.dot', {title: 'My title'}));
as in your readme.
If the person creating the templates can't do this because they are creating a theme for example, they need another way to declare the layout template.
from dot-view.
To be clearer, say I have this layout file default.dot
like in your readme example:
<!DOCTYPE html>
<html>
<head>
<title>{{=it.title}}</title>
</head>
<body>
<div>{{#def._content}}</div>
</body>
</html>
If I decide I want to use that as my layout for a template page.dot
I could do something like:
{{< default }}
<div>Some content!</div>
Where I have created the syntax {{< layoutName }}
for declaring the layout template to use.
It would be equivalent to doing this in code:
var pageView = new View('/tpl/path', 'page.dot');
pageView.layout(new View('/layouts', 'default.dot', {title: 'My title'}));
var html = pageView.render();
from dot-view.
Clear! Thanks for the elaborate explanation. As dot-view
is merely a wrapper for doT
, so I feel a bit uncomfortable adding new template syntax as these templates would stop working with native doT
then. Isn't this something that should be done in the compiler function of doT
itself?
Otherwise I can only include things in the template for dot-view
to pick up that don't hurt the normal doT template rendering function, like: {{var layout = 'layout.dot';}}
at the top of a sub-template or even something as simple as {{'layout:layout.dot';}}
or a dummy define {{##def.layout:layout.dot#}}
.
I like the last option best as this way no unused garbage ends up in the compiled doT
template function.
from dot-view.
Yeah that's true, it would either have to be done in doT itself or the new syntax would have to seem like a comment to doT so that it has no side effect to existing template files.
from dot-view.
I would be interested in a solution using your last suggestion too.
On 16 Jan 2015 04:32, "Bart" [email protected] wrote:
Clear! Thanks for the elaborate explanation. As dot-view is merely a
wrapper for doT, so I feel a bit uncomfortable adding new template syntax
as these templates would stop working with native doT then. Isn't this
something that should be done in the compiler function of doT itself?Otherwise I can only include things in the template for dot-view to pick
up that don't hurt the normal doT template rendering function, like: {{var
layout = 'layout.dot';}} at the top of a sub-template or even something
as simple as {{'layout:layout.dot';}} or a dummy define
{{##def.layout:layout.dot#}}.I like the last option best as this way no unused garbage ends up in the
compiled doT template function.—
Reply to this email directly or view it on GitHub
#1 (comment).
from dot-view.
I wanted to use the comment options too, but as far as I could see doT
has no comment syntax of its own and javascript comment {{/* layout.dot */}}
results in a literal {{}}
being added to the template output because it isn't picked up by any of the regular expressions.
from dot-view.
I'm not sure if it still applies but I saw this
olado/doT#68
On 16 Jan 2015 04:46, "Bart" [email protected] wrote:
I wanted to use the comment options too, but as far as I could see doT
has no comment syntax of its own and javascript comment {{/* layout.dot
*/}} result in a literal {{}} being added to the template output because
it isn't picked up by any of the regular expressions.—
Reply to this email directly or view it on GitHub
#1 (comment).
from dot-view.
Thanks, that link got me trying some more variations as {{/* test */}}
didn't work,
but {{ /*test*/ }}
and even {{ /*test*/}}
work! How does {{ /* layout:layout.dot */ }}
look?
from dot-view.
Interesting find. That looks good enough!
On 16 Jan 2015 05:08, "Bart" [email protected] wrote:
Thanks, that link got me trying some more variations as {{/* test /}}
didn't work, but {{ /test/ }} and even {{ /test/}} work! How does {{
/ layout:layout.dot */ }} look?—
Reply to this email directly or view it on GitHub
#1 (comment).
from dot-view.
I'm busy this weekend, but I'll add this somewhere next week.
I've already built a regex /\{\{\s+\/\*\s*layout:(.+\S+)\s*\*\/\s*\}\}/
which should do the trick.
doT
allows you to override the replacement delimiters {{...}}, but for now as a first implementation I'm going to assume {{ and }} are used. I can always make the regex above configurable just the way doT
does.
from dot-view.
Cool, I think something like your other suggestion would be fine too by the way if you prefer that: {{##def._layout:layout.dot#}}
from dot-view.
The cool thing is the regular expression to pick up the layout will be configurable just like the doT
tags, so you can use any tag syntax you like. I'll default to {{ /* layout:layout.dot */ }}
as this method is 100% safe.
Edit: Hmm, on the other hand {{##def._layout:layout.dot#}}
would be compatible with the way the template content is placed in the layout with {{#def._content}}
.
Update: I will also include {{#def.include('path/to/sub-template.dot')}}
to include sub-templates from a template file rather than from code.
from dot-view.
See release 0.3.0
from dot-view.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dot-view.