Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 82 lines (53 sloc) 1.295 kb
ed832ec Mario Gutierrez sorted features
authored
1 # Func'd
9db9eb2 Mario Gutierrez first commit
authored
2
3 Template engine in the style of Builder, Markaby, Erector.
4
ed832ec Mario Gutierrez sorted features
authored
5 * Blocks
9db9eb2 Mario Gutierrez first commit
authored
6 * Layouts
ed832ec Mario Gutierrez sorted features
authored
7 * Mixins
8 * Just functions
9db9eb2 Mario Gutierrez first commit
authored
9 * Partials
ed832ec Mario Gutierrez sorted features
authored
10 * Safe HTML
9db9eb2 Mario Gutierrez first commit
authored
11
12 ## Installation
13
14 npm install funcd
15
16 ## Features
17
18 Using
19
20 Funcd = require("funcd")
21
48da041 Mario Gutierrez documentation cleanup
authored
22 Layouts and partials
9db9eb2 Mario Gutierrez first commit
authored
23
11389ee Mario Gutierrez Heavily refactored, major changes
authored
24 layout = ->
25 @doctype 5
26 @html ->
27 @head ->
28 @script src: "js/jquery.js"
29 @block "page-scripts"
30 @body ->
31 @block "body"
9db9eb2 Mario Gutierrez first commit
authored
32
11389ee Mario Gutierrez Heavily refactored, major changes
authored
33 footer = (text) ->
34 @div id: "footer", text
9db9eb2 Mario Gutierrez first commit
authored
35
36 page = (name) ->
11389ee Mario Gutierrez Heavily refactored, major changes
authored
37 @extends layout
9db9eb2 Mario Gutierrez first commit
authored
38
11389ee Mario Gutierrez Heavily refactored, major changes
authored
39 @block "body", ->
40 @h1 "Simple Page"
41 @div "Hello #{name}"
42 @render footer "page1"
9db9eb2 Mario Gutierrez first commit
authored
43
48da041 Mario Gutierrez documentation cleanup
authored
44 html = Funcd.render(page, "kitty!")
9db9eb2 Mario Gutierrez first commit
authored
45
46
48da041 Mario Gutierrez documentation cleanup
authored
47 Mixins
9db9eb2 Mario Gutierrez first commit
authored
48
49 mixins =
11389ee Mario Gutierrez Heavily refactored, major changes
authored
50 info: (block) ->
51 @div class: 'info', block
9db9eb2 Mario Gutierrez first commit
authored
52
11389ee Mario Gutierrez Heavily refactored, major changes
authored
53 template = ->
54 @info ->
55 @div "bah"
48da041 Mario Gutierrez documentation cleanup
authored
56
57 # <div class="info"><div>bah</div></div>
58 Funcd.render mixins: mixins, template
9db9eb2 Mario Gutierrez first commit
authored
59
60
48da041 Mario Gutierrez documentation cleanup
authored
61 Safe HTML
9db9eb2 Mario Gutierrez first commit
authored
62
48da041 Mario Gutierrez documentation cleanup
authored
63 # <a>1 &lt; 2</a>
11389ee Mario Gutierrez Heavily refactored, major changes
authored
64 Funcd.render -> @a "1 < 2"
9db9eb2 Mario Gutierrez first commit
authored
65
48da041 Mario Gutierrez documentation cleanup
authored
66 # <a><i>apple</i></a>
11389ee Mario Gutierrez Heavily refactored, major changes
authored
67 Funcd.render -> @a @raw("<i>apple</i>")
9db9eb2 Mario Gutierrez first commit
authored
68
69
0ce268d Mario Gutierrez add async functions
authored
70 Render from files
71
11389ee Mario Gutierrez Heavily refactored, major changes
authored
72 # test.coffee
73 module.exports = (name, city) ->
74 @div name + " " + city
0ce268d Mario Gutierrez add async functions
authored
75
76 # <div>foo San Diego</div>
11389ee Mario Gutierrez Heavily refactored, major changes
authored
77 Funcd.renderFile "#{__dirname}/test.coffee", "foo", "San Diego"
0ce268d Mario Gutierrez add async functions
authored
78
11389ee Mario Gutierrez Heavily refactored, major changes
authored
79 ### Licensed Under MIT License
0ce268d Mario Gutierrez add async functions
authored
80
11389ee Mario Gutierrez Heavily refactored, major changes
authored
81 See the file LICENSE
Something went wrong with that request. Please try again.