Open totkeks opened 11 years ago
It works for me, @Pitmairen would you please put it in the master branch, thx a lot! :)
I'm a little unsure about this.
Usually when using jinja you have a base template that the other templates are extending. So the doctype is needed only once in the base template. And also the html5 doctype is so simple and easy to remember that i think it's a little unnecessary to add a new syntax just for the doctype.
Another way to do this is simply using the existing syntax for variables and add the necessary doctypes to the jinja global variables. It will become something like this:
=html5
%html
%head
...
thx a lot! That's works for me. After adding jinja global variables, I changed my doctype like this:
=html5|safe
If you use the jinja2.Markup class when creating the docstring variable you don't need use the safe filter.
jinja_env.globals['html5'] = jinja2.Markup('<!DOCTYPE html>')
Thanks for your time on this issue. :)
-macro doctype(content):
='<!DOCTYPE ' + content + '>'
=doctype('html')
I tried to use !!! as a shortcut (as pointed out in this nice example: https://gist.github.com/2502955) and was a bit disappointed that it didn't work. So I quickly wrote this patch to add the required doctype strings. This is just the basic idea, I guess using a custom node type (e.g. DocType) could be a bit better, since a lot of the whole doctype string is shared between all of them.
Feedback is welcome!