How to use the compile function from jade

Find comprehensive JavaScript jade.compile code examples handpicked from public code repositorys.

40
41
42
43
44
45
46
47
48
49
returnsfunction
A function to generate the html from an object containing locals
var jade = require('jade');

// Compile a function
var fn = jade.compile('string of jade', options);

// Render the function
var html = fn(locals);
// => '<string>of jade</string>'
fork icon21
star icon24
watch icon7

3
4
5
6
7
8
9
10
11
12

exports.name = 'jade'
exports.outputFormat = 'html'

exports.compile = function (source, options) {
  const fn = jade.compile(source, options)
  return {
    fn,
    dependencies: fn.dependencies
  }
fork icon1
star icon0
watch icon3

3
4
5
6
7
8
9
10
11
12
var jade = require('jade')


var TEMPLATES = {
  main: jade.compile(Buffer("bmF2Lm5hdmJhci5uYXZiYXItZGVmYXVsdAogIC5jb250YWluZXItZmx1aWQKICAgIC5uYXZiYXItaGVhZGVyCiAgICAgIGEubmF2YmFyLWJyYW5kKGhyZWY9J2h0dHA6Ly9tZXRlb3ItZGFwcC1ib2FyZHJvb20ubWV0ZW9yLmNvbS8nKQogICAgICAgIGkuZ2x5cGhpY29uLnRleHQtcHJpbWFyeS5nbHlwaGljb24ta25pZ2h0CiAgICAgICAgfCAgQm9hcmRSb29tCiAgICB8ICAgICAgICAgICAgIAogICAgfCAgICAgICAgICAgICAKICAgIHVsLm5hdi5uYXZiYXItbmF2Lm5hdmJhci1yaWdodC5uYXZiYXItYnJhbmQKICAgICAgYS5kYXBwLWlkZW50aWNvbi5kYXBwLWlkZW50aWNvbi1kZWZhdWx0LmRhcHAtc21hbGwoaHJlZj0nIycpCiAgICAgIHwgICAgICAgICAgICAgICAKICAgICAgc3Bhbi5jdXJyZW50LXVzZXIgQWFyb24gRGF2aXMKCm1haW4uY29udGFpbmVyLWZsdWlkCgogIC8vIGJyZWFkY3J1bWJzCiAgZWFjaCB2aWV3UGF0aCwgaW5kZXggaW4gdmlld1N0YWNrCiAgICBpZiBpbmRleCAhPT0gMAogICAgICB8ICAmZ3Q7CiAgICAgIHwgICAKICAgIC0gdmFyIGZ1bGxQYXRoID0gdmlld1N0YWNrLnNsaWNlKDAsaW5kZXgrMSkuam9pbignfCcpCiAgICBhLmJ0bi1uYXYuYnJlYWQtY3J1bWIoIGRhdGEtdGFyZ2V0PSIje2Z1bGxQYXRofSIgKSAje3ZpZXdQYXRofQoKICBicgoKICAvLyBtYWluIGNvbnRlbnQKICAucm93LWZsdWlkLmNvbnRlbnQtaG9tZQogICAgLnRlbXBsYXRlLXlpZWxkCiAgICAKZm9vdGVyLmZvb3Rlcm5hdgogIHAuY29weXJpZ2h0LnRleHQtbXV0ZWQuc21hbGwgQ29weXJpZ2h0ICZjb3B5OyAmRVRIO0FwcCBCb2FyZFJvb20gMjAxNS4gQWxsIFJpZ2h0cyBSZXNlcnZlZAoK","base64").toString()),
  home: jade.compile(Buffer("aDEgV2VsY29tZSB0byBCb2FyZFJvb20KYnIKYS5idG4tbmF2KCBkYXRhLXRhcmdldD0ibWFpbnxib2FyZHMiICkgQWN0aXZlIGJvYXJkcyAoI3tPYmplY3Qua2V5cyhib2FyZHMpLmxlbmd0aH0pCmJyCmEuYnRuLW5hdiggZGF0YS10YXJnZXQ9Im1haW58b2ZmZXJzIiApIFB1YmxpYyBvZmZlcnMgKCN7T2JqZWN0LmtleXMob2ZmZXJzKS5sZW5ndGh9KQ==","base64").toString()),
  
  offers: jade.compile(Buffer("aDMgUHVibGljIE9mZmVycwoKLnlpZWxkCiAgCiAgdWwKICBlYWNoIG9mZmVyLCBpbmRleCBpbiBvZmZlcnMKICAgIGxpCiAgICAgIGEuYnRuLW5hdiggZGF0YS10YXJnZXQ9Im1haW58b2ZmZXJzfG9mZmVyOm9mZmVycy4je2luZGV4fSIgKT0gQVBQX1NUQVRFLmJvYXJkc1tvZmZlci5rZXldLm5hbWUK","base64").toString()),
  offer: jade.compile(Buffer("aDMgVmFwb3IgUHVibGljIE9mZmVyCmEuYnRuLW5hdiggZGF0YS10YXJnZXQ9Im1haW58Ym9hcmRzfGJvYXJkOmJvYXJkcy4je2tleX0iICkgU2VlIEJvYXJkCiAgICAgICAgICAKYnIKYnIKCnNwYW4ucHVibGljLW9mZmVyLWRlc2NyaXB0aW9uCiAgc3Ryb25nIFZhcG9yCiAgfCAgaXMgb2ZmZXJpbmcgCiAgc3Ryb25nIDIwJQogIHwgIG93bmVyc2hpcCBmb3IgCiAgc3Ryb25nIDEwMGsgVVNECgpicgpicgoKYnV0dG9uKAogIG9uY2xpY2s9J3dpbmRvdy50YWtlT2ZmZXIoIiN7a2V5fSIpJwopIFRha2UgT2ZmZXI=","base64").toString()),
  
fork icon0
star icon1
watch icon3

+ 13 other calls in file

30
31
32
33
34
35
36
37
38
39
40
41


function loadJadeTemplates()
{
	var options = {pretty:true};


	var singlechoice = jade.compile(fs.readFileSync('jade/singlechoice.jade', 'utf8'),options);
	var multichoice = jade.compile(fs.readFileSync('jade/multichoice.jade', 'utf8'),options);
	var singlechoicetable = jade.compile(fs.readFileSync('jade/singlechoicetable.jade', 'utf8'),options);
	var multichoicetable = jade.compile(fs.readFileSync('jade/multichoicetable.jade', 'utf8'),options);
	var text = jade.compile(fs.readFileSync('jade/text.jade', 'utf8'),options);
fork icon0
star icon0
watch icon0

+ 15 other calls in file