Jade access filname inside render

52 views
Skip to first unread message

samur...@gmail.com

unread,
Sep 8, 2014, 7:36:01 AM9/8/14
to jad...@googlegroups.com

Can I access the filename attribute within the render function.

Blockquote jade.renderFile(filename, options)

filename - string The path to the jade file to render options

options - An options object (see above), also used as the locals object

returns string The resulting html string

For example I render a page

var jade = require('jade');

 

var html = jade.renderFile('path/to/file.jade', options);

can I access 'path/to/file.jade' in file.jade.

Usage is for example an include to header.jade from all my pages, in the header.jade I want to load section dependant on the filname.

i.e. faq loads different classes in the header then say index.

-if (this.filename != index.jade)

I could circumvent using another options variables but its not so nice.

Forbes Lindesay

unread,
Sep 8, 2014, 10:34:19 AM9/8/14
to jad...@googlegroups.com
If you use the remderFile API, it is available inside your template as `filename`.  Don't forget to quote your string liberals though.

Forbes Lindesay
--
You received this message because you are subscribed to the Google Groups "Jade" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jadejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages