jade-marko0.1.5 • Public • Published
Jade compilation for Markoa templates
Install the module with:
npm install jade-markoa
jadeMarko transformation to compile jade files to marko files. Jade doesn't care about the tag name, so we can use it with marko tags and custom tags without any problem :)
In order to facilitate using templates from other packages with
include you can use the special
package:: prefix. This will calculate the relative path to the
node_modules of your project, given you pass in a
rootPath entry in your gulp options.
Note: You can also pass:
log: true to enable some basic logging.
var options =rootPath: __dirnamelog: true;gulp
Then use it in your templates like this
Which will resolve to something like:
If you don't supply a
../../.. will be used as the default
Custom template folder aliases
You can supply your own custom template folder aliases, similar to
templateDirs:global: pathlayout: '../layouts''parent-layout': '../../layouts'
Your jade file:
extends package::global/layout.jadeextends parent-layout::base.jadeextends mixin::list.jade
Pre-compiled jade file:
extends ../../../node_modules/global/layout.jadeextends ../../layouts/base.jadeextends ../mixins/list.jade
Which is then transformed to Marko ;)
In order for Jade to work correctly with Marko, there are a few little gotchas. Both Jade and Marko use the same special keywords for constructs, such as:
In order for Jade to not treat these as Jade language constructs, use
x- equivalents like this:
xvar(a='17')xif(test='a = b')$data.axelse-if(test='a = c')$data.cxelse$data.d
Otherwise you are "good to go" with the usual Jade syntax. You can even mix in with Jade conditional logic if you like ;)
doctype htmlhtmlheadblock titletitle Default titlebodyblock content
extends layout.jadeblock titletitle Article Titleblock contenth1 My Articleasync-fragment(data="data")xvar(a='17')xif(test='a = b')$data.axelse-if(test='a = c')$data.cxelse$data.d
.marko files in
gulp jade:marko and check that
apps/index now contains
.marko files for the jade templates.
Article TitleMy Article$data.a$data.c$data.d
Please submit all issues and pull requests to the kristianmandrup/jade-markoa repository!
If you have any problem or suggestion please open an issue here.
The MIT License
Copyright (c) 2015, Kristian Mandrup
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.