mustache 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +30 -179
- data/Rakefile +87 -46
- data/bin/mustache +10 -19
- data/lib/mustache/context.rb +55 -12
- data/lib/mustache/sinatra.rb +1 -1
- data/lib/mustache/template.rb +3 -15
- data/lib/mustache/version.rb +1 -1
- data/man/mustache.1 +138 -0
- data/man/mustache.1.html +168 -0
- data/man/mustache.1.ron +94 -0
- data/man/mustache.5 +364 -0
- data/man/mustache.5.html +300 -0
- data/man/mustache.5.ron +220 -0
- data/test/helper.rb +1 -0
- data/test/mustache_test.rb +25 -16
- metadata +32 -65
- data/.gitignore +0 -1
- data/.kick +0 -26
- data/CONTRIBUTORS +0 -6
- data/HISTORY.md +0 -70
- data/benchmarks/complex.erb +0 -15
- data/benchmarks/complex.haml +0 -10
- data/benchmarks/helper.rb +0 -20
- data/benchmarks/simple.erb +0 -5
- data/benchmarks/speed.rb +0 -76
- data/contrib/mustache.vim +0 -69
- data/contrib/tpl-mode.el +0 -274
- data/examples/comments.mustache +0 -1
- data/examples/comments.rb +0 -14
- data/examples/complex_view.mustache +0 -16
- data/examples/complex_view.rb +0 -34
- data/examples/delimiters.mustache +0 -6
- data/examples/delimiters.rb +0 -22
- data/examples/double_section.mustache +0 -7
- data/examples/double_section.rb +0 -14
- data/examples/escaped.mustache +0 -1
- data/examples/escaped.rb +0 -14
- data/examples/inner_partial.mustache +0 -1
- data/examples/inner_partial.txt +0 -1
- data/examples/namespaced.mustache +0 -1
- data/examples/namespaced.rb +0 -25
- data/examples/partial_with_module.mustache +0 -3
- data/examples/partial_with_module.rb +0 -37
- data/examples/passenger.conf +0 -5
- data/examples/passenger.rb +0 -27
- data/examples/simple.mustache +0 -5
- data/examples/simple.rb +0 -26
- data/examples/template_partial.mustache +0 -2
- data/examples/template_partial.rb +0 -18
- data/examples/template_partial.txt +0 -4
- data/examples/unescaped.mustache +0 -1
- data/examples/unescaped.rb +0 -14
data/contrib/mustache.vim
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
" Vim syntax file
|
|
2
|
-
" Language: Mustache
|
|
3
|
-
" Maintainer: Juvenn Woo <machese@gmail.com>
|
|
4
|
-
" Screenshot: http://imgur.com/6F408
|
|
5
|
-
" Version: 1
|
|
6
|
-
" Last Change: 2009 Oct 15
|
|
7
|
-
" Remark:
|
|
8
|
-
" It lexically hilights embedded mustaches (exclusively) in html file.
|
|
9
|
-
" While it was written for Ruby-based Mustache template system, it should work for Google's C-based *ctemplate* as well as Erlang-based *et*. All of them are, AFAIK, based on the idea of ctemplate.
|
|
10
|
-
" References:
|
|
11
|
-
" [Mustache](http://github.com/defunkt/mustache)
|
|
12
|
-
" [ctemplate](http://code.google.com/p/google-ctemplate/)
|
|
13
|
-
" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html)
|
|
14
|
-
" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html)
|
|
15
|
-
" TODO: Feedback is welcomed.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
" Read the HTML syntax to start with
|
|
19
|
-
if version < 600
|
|
20
|
-
so <sfile>:p:h/html.vim
|
|
21
|
-
else
|
|
22
|
-
runtime! syntax/html.vim
|
|
23
|
-
unlet b:current_syntax
|
|
24
|
-
endif
|
|
25
|
-
|
|
26
|
-
if version < 600
|
|
27
|
-
syntax clear
|
|
28
|
-
elseif exists("b:current_syntax")
|
|
29
|
-
finish
|
|
30
|
-
endif
|
|
31
|
-
|
|
32
|
-
" Standard HiLink will not work with included syntax files
|
|
33
|
-
if version < 508
|
|
34
|
-
command! -nargs=+ HtmlHiLink hi link <args>
|
|
35
|
-
else
|
|
36
|
-
command! -nargs=+ HtmlHiLink hi def link <args>
|
|
37
|
-
endif
|
|
38
|
-
|
|
39
|
-
syntax match mustacheError '}}}\?'
|
|
40
|
-
syntax match mustacheInsideError '{{[{#<>=!\/]\?' containedin=@mustacheInside
|
|
41
|
-
syntax region mustacheVariable matchgroup=mustacheMarker start=/{{/ end=/}}/ containedin=@htmlMustacheContainer
|
|
42
|
-
syntax region mustacheVariableUnescape matchgroup=mustacheMarker start=/{{{/ end=/}}}/ containedin=@htmlMustacheContainer
|
|
43
|
-
syntax region mustacheSection matchgroup=mustacheMarker start='{{[#/]' end=/}}/ containedin=@htmlMustacheContainer
|
|
44
|
-
syntax region mustachePartial matchgroup=mustacheMarker start=/{{[<>]/ end=/}}/
|
|
45
|
-
syntax region mustacheMarkerSet matchgroup=mustacheMarker start=/{{=/ end=/=}}/
|
|
46
|
-
syntax region mustacheComment start=/{{!/ end=/}}/ contains=Todo containedin=htmlHead
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
" Clustering
|
|
50
|
-
syntax cluster mustacheInside add=mustacheVariable,mustacheVariableUnescape,mustacheSection,mustachePartial,mustacheMarkerSet
|
|
51
|
-
syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
" Hilighting
|
|
55
|
-
" mustacheInside hilighted as Number, which is rarely used in html
|
|
56
|
-
" you might like change it to Function or Identifier
|
|
57
|
-
HtmlHiLink mustacheVariable Number
|
|
58
|
-
HtmlHiLink mustacheVariableUnescape Number
|
|
59
|
-
HtmlHiLink mustachePartial Number
|
|
60
|
-
HtmlHiLink mustacheSection Number
|
|
61
|
-
HtmlHiLink mustacheMarkerSet Number
|
|
62
|
-
|
|
63
|
-
HtmlHiLink mustacheComment Comment
|
|
64
|
-
HtmlHiLink mustacheMarker Identifier
|
|
65
|
-
HtmlHiLink mustacheError Error
|
|
66
|
-
HtmlHiLink mustacheInsideError Error
|
|
67
|
-
|
|
68
|
-
let b:current_syntax = "mustache"
|
|
69
|
-
delcommand HtmlHiLink
|
data/contrib/tpl-mode.el
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
;;; tpl-mode.el -- a major mode for editing Google CTemplate files.
|
|
2
|
-
;;; By Tony Gentilcore, July 2006
|
|
3
|
-
;;;
|
|
4
|
-
;;; Very minor, backwards compatible changes added for Mustache compatibility
|
|
5
|
-
;;; by Chris Wanstrath, October 2009
|
|
6
|
-
;;;
|
|
7
|
-
;;; TO USE:
|
|
8
|
-
;;; 1) Copy this file somewhere you in emacs load-path. To see what
|
|
9
|
-
;;; your load-path is, run inside emacs: C-h v load-path<RET>
|
|
10
|
-
;;; 2) Add the following two lines to your .emacs file:
|
|
11
|
-
;;; (setq auto-mode-alist (cons '("\\.tpl$" . tpl-mode) auto-mode-alist))
|
|
12
|
-
;;; (autoload 'tpl-mode "tpl-mode" "Major mode for editing CTemplate files." t)
|
|
13
|
-
;;; 3) Optionally (but recommended), add this third line as well:
|
|
14
|
-
;;; (add-hook 'tpl-mode-hook '(lambda () (font-lock-mode 1)))
|
|
15
|
-
;;; ---
|
|
16
|
-
;;;
|
|
17
|
-
;;; While the CTemplate language can be used for any types of text,
|
|
18
|
-
;;; this mode is intended for using CTemplate to write HTML.
|
|
19
|
-
;;;
|
|
20
|
-
;;; The indentation still has minor bugs due to the fact that
|
|
21
|
-
;;; templates do not require valid HTML.
|
|
22
|
-
;;;
|
|
23
|
-
;;; It would be nice to be able to highlight attributes of HTML tags,
|
|
24
|
-
;;; however this is difficult due to the presence of CTemplate symbols
|
|
25
|
-
;;; embedded within attributes.
|
|
26
|
-
|
|
27
|
-
(eval-when-compile
|
|
28
|
-
(require 'font-lock))
|
|
29
|
-
|
|
30
|
-
(defgroup tpl-mode nil
|
|
31
|
-
"Major mode for editing Google CTemplate and Mustache files"
|
|
32
|
-
:group 'languages)
|
|
33
|
-
|
|
34
|
-
(defvar tpl-mode-version "1.1"
|
|
35
|
-
"Version of `tpl-mode.el'.")
|
|
36
|
-
|
|
37
|
-
(defvar tpl-mode-abbrev-table nil
|
|
38
|
-
"Abbrev table for use in tpl-mode buffers.")
|
|
39
|
-
|
|
40
|
-
(define-abbrev-table 'tpl-mode-abbrev-table ())
|
|
41
|
-
|
|
42
|
-
(defcustom tpl-mode-hook nil
|
|
43
|
-
"*Hook that runs upon entering tpl-mode."
|
|
44
|
-
:type 'hook)
|
|
45
|
-
|
|
46
|
-
(defvar tpl-mode-map nil
|
|
47
|
-
"Keymap for tpl-mode major mode")
|
|
48
|
-
|
|
49
|
-
(if tpl-mode-map
|
|
50
|
-
nil
|
|
51
|
-
(setq tpl-mode-map (make-sparse-keymap)))
|
|
52
|
-
|
|
53
|
-
(define-key tpl-mode-map "\t" 'tpl-indent-command)
|
|
54
|
-
(define-key tpl-mode-map "\C-m" 'reindent-then-newline-and-indent)
|
|
55
|
-
(define-key tpl-mode-map "\C-ct" 'tpl-insert-tag)
|
|
56
|
-
(define-key tpl-mode-map "\C-cv" 'tpl-insert-variable)
|
|
57
|
-
(define-key tpl-mode-map "\C-cs" 'tpl-insert-section)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
(defvar tpl-mode-syntax-table nil
|
|
61
|
-
"Syntax table in use in tpl-mode buffers.")
|
|
62
|
-
|
|
63
|
-
;; Syntax table.
|
|
64
|
-
(if tpl-mode-syntax-table
|
|
65
|
-
nil
|
|
66
|
-
(setq tpl-mode-syntax-table (make-syntax-table text-mode-syntax-table))
|
|
67
|
-
(modify-syntax-entry ?< "(> " tpl-mode-syntax-table)
|
|
68
|
-
(modify-syntax-entry ?> ")< " tpl-mode-syntax-table)
|
|
69
|
-
(modify-syntax-entry ?\" ". " tpl-mode-syntax-table)
|
|
70
|
-
(modify-syntax-entry ?\\ ". " tpl-mode-syntax-table)
|
|
71
|
-
(modify-syntax-entry ?' "w " tpl-mode-syntax-table))
|
|
72
|
-
|
|
73
|
-
(defvar tpl-basic-offset 2
|
|
74
|
-
"The basic indentation offset.")
|
|
75
|
-
|
|
76
|
-
;; Constant regular expressions to identify template elements.
|
|
77
|
-
(defconst tpl-mode-tpl-token "[a-zA-Z][a-zA-Z0-9_:=\?!-]*?")
|
|
78
|
-
(defconst tpl-mode-section (concat "\\({{[#/]\s*"
|
|
79
|
-
tpl-mode-tpl-token
|
|
80
|
-
"\s*}}\\)"))
|
|
81
|
-
(defconst tpl-mode-open-section (concat "\\({{#\s*"
|
|
82
|
-
tpl-mode-tpl-token
|
|
83
|
-
"\s*}}\\)"))
|
|
84
|
-
(defconst tpl-mode-close-section (concat "{{/\\(\s*"
|
|
85
|
-
tpl-mode-tpl-token
|
|
86
|
-
"\s*\\)}}"))
|
|
87
|
-
;; TODO(tonyg) Figure out a way to support multiline comments.
|
|
88
|
-
(defconst tpl-mode-comment "\\({{!.*?}}\\)")
|
|
89
|
-
(defconst tpl-mode-include (concat "\\({{>\s*"
|
|
90
|
-
tpl-mode-tpl-token
|
|
91
|
-
"\s*}}\\)"))
|
|
92
|
-
(defconst tpl-mode-variable (concat "\\({{\s*"
|
|
93
|
-
tpl-mode-tpl-token
|
|
94
|
-
"\s*}}\\)"))
|
|
95
|
-
(defconst tpl-mode-builtins
|
|
96
|
-
(concat
|
|
97
|
-
"\\({{\\<\s*"
|
|
98
|
-
(regexp-opt
|
|
99
|
-
'("BI_NEWLINE" "BI_SPACE")
|
|
100
|
-
t)
|
|
101
|
-
"\s*\\>}}\\)"))
|
|
102
|
-
(defconst tpl-mode-close-section-at-start (concat "^[ \t]*?"
|
|
103
|
-
tpl-mode-close-section))
|
|
104
|
-
|
|
105
|
-
;; Constant regular expressions to identify html tags.
|
|
106
|
-
;; Taken from HTML 4.01 / XHTML 1.0 Reference found at:
|
|
107
|
-
;; http://www.w3schools.com/tags/default.asp.
|
|
108
|
-
(defconst tpl-mode-html-constant "\\(&#?[a-z0-9]\\{2,5\\};\\)")
|
|
109
|
-
(defconst tpl-mode-pair-tag
|
|
110
|
-
(concat
|
|
111
|
-
"\\<"
|
|
112
|
-
(regexp-opt
|
|
113
|
-
'("a" "abbr" "acronym" "address" "applet" "area" "b" "bdo"
|
|
114
|
-
"big" "blockquote" "body" "button" "caption" "center" "cite"
|
|
115
|
-
"code" "col" "colgroup" "dd" "del" "dfn" "dif" "div" "dl"
|
|
116
|
-
"dt" "em" "fieldset" "font" "form" "frame" "frameset" "h1"
|
|
117
|
-
"h2" "h3" "h4" "h5" "h6" "head" "html" "i" "iframe" "ins"
|
|
118
|
-
"kbd" "label" "legend" "li" "link" "map" "menu" "noframes"
|
|
119
|
-
"noscript" "object" "ol" "optgroup" "option" "p" "pre" "q"
|
|
120
|
-
"s" "samp" "script" "select" "small" "span" "strike"
|
|
121
|
-
"strong" "style" "sub" "sup" "table" "tbody" "td" "textarea"
|
|
122
|
-
"tfoot" "th" "thead" "title" "tr" "tt" "u" "ul" "var")
|
|
123
|
-
t)
|
|
124
|
-
"\\>"))
|
|
125
|
-
(defconst tpl-mode-standalone-tag
|
|
126
|
-
(concat
|
|
127
|
-
"\\<"
|
|
128
|
-
(regexp-opt
|
|
129
|
-
'("base" "br" "hr" "img" "input" "meta" "param")
|
|
130
|
-
t)
|
|
131
|
-
"\\>"))
|
|
132
|
-
(defconst tpl-mode-open-tag (concat "<\\("
|
|
133
|
-
tpl-mode-pair-tag
|
|
134
|
-
"\\)"))
|
|
135
|
-
(defconst tpl-mode-close-tag (concat "</\\("
|
|
136
|
-
tpl-mode-pair-tag
|
|
137
|
-
"\\)>"))
|
|
138
|
-
(defconst tpl-mode-close-tag-at-start (concat "^[ \t]*?"
|
|
139
|
-
tpl-mode-close-tag))
|
|
140
|
-
|
|
141
|
-
(defconst tpl-mode-blank-line "^[ \t]*?$")
|
|
142
|
-
(defconst tpl-mode-dangling-open (concat "\\("
|
|
143
|
-
tpl-mode-open-section
|
|
144
|
-
"\\)\\|\\("
|
|
145
|
-
tpl-mode-open-tag
|
|
146
|
-
"\\)[^/]*$"))
|
|
147
|
-
|
|
148
|
-
(defun tpl-indent-command ()
|
|
149
|
-
"Command for indenting text. Just calls tpl-indent."
|
|
150
|
-
(interactive)
|
|
151
|
-
(tpl-indent))
|
|
152
|
-
|
|
153
|
-
(defun tpl-insert-tag (tag)
|
|
154
|
-
"Inserts an HTML tag."
|
|
155
|
-
(interactive "sTag: ")
|
|
156
|
-
(tpl-indent)
|
|
157
|
-
(insert (concat "<" tag ">"))
|
|
158
|
-
(insert "\n\n")
|
|
159
|
-
(insert (concat "</" tag ">"))
|
|
160
|
-
(tpl-indent)
|
|
161
|
-
(forward-line -1)
|
|
162
|
-
(tpl-indent))
|
|
163
|
-
|
|
164
|
-
(defun tpl-insert-variable (variable)
|
|
165
|
-
"Inserts a tpl variable."
|
|
166
|
-
(interactive "sVariable: ")
|
|
167
|
-
(insert (concat "{{" variable "}}")))
|
|
168
|
-
|
|
169
|
-
(defun tpl-insert-section (section)
|
|
170
|
-
"Inserts a tpl section."
|
|
171
|
-
(interactive "sSection: ")
|
|
172
|
-
(tpl-indent)
|
|
173
|
-
(insert (concat "{{#" section "}}\n"))
|
|
174
|
-
(insert "\n")
|
|
175
|
-
(insert (concat "{{/" section "}}"))
|
|
176
|
-
(tpl-indent)
|
|
177
|
-
(forward-line -1)
|
|
178
|
-
(tpl-indent))
|
|
179
|
-
|
|
180
|
-
;; Function to control indenting.
|
|
181
|
-
(defun tpl-indent ()
|
|
182
|
-
"Indent current line"
|
|
183
|
-
;; Set the point to beginning of line.
|
|
184
|
-
(beginning-of-line)
|
|
185
|
-
;; If we are at the beginning of the file, indent to 0.
|
|
186
|
-
(if (bobp)
|
|
187
|
-
(indent-line-to 0)
|
|
188
|
-
(let ((tag-stack 1) (close-tag "") (cur-indent 0) (old-pnt (point-marker))
|
|
189
|
-
(close-at-start) (open-token) (dangling-open))
|
|
190
|
-
(progn
|
|
191
|
-
;; Determine if this is a template line or an html line.
|
|
192
|
-
(if (looking-at "^[ \t]*?{{")
|
|
193
|
-
(setq close-at-start tpl-mode-close-section-at-start
|
|
194
|
-
open-token "{{#")
|
|
195
|
-
(setq close-at-start tpl-mode-close-tag-at-start
|
|
196
|
-
open-token "<"))
|
|
197
|
-
;; If there is a closing tag at the start of the line, search back
|
|
198
|
-
;; for its opener and indent to that level.
|
|
199
|
-
(if (looking-at close-at-start)
|
|
200
|
-
(progn
|
|
201
|
-
(save-excursion
|
|
202
|
-
(setq close-tag (match-string 1))
|
|
203
|
-
;; Keep searching for a match for the close tag until
|
|
204
|
-
;; the tag-stack is 0.
|
|
205
|
-
(while (and (not (bobp))
|
|
206
|
-
(> tag-stack 0)
|
|
207
|
-
(re-search-backward (concat open-token
|
|
208
|
-
"\\(/?\\)"
|
|
209
|
-
close-tag) nil t))
|
|
210
|
-
(if (string-equal (match-string 1) "/")
|
|
211
|
-
;; We found another close tag, so increment tag-stack.
|
|
212
|
-
(setq tag-stack (+ tag-stack 1))
|
|
213
|
-
;; We found an open tag, so decrement tag-stack.
|
|
214
|
-
(setq tag-stack (- tag-stack 1)))
|
|
215
|
-
(setq cur-indent (current-indentation))))
|
|
216
|
-
(if (> tag-stack 0)
|
|
217
|
-
(save-excursion
|
|
218
|
-
(forward-line -1)
|
|
219
|
-
(setq cur-indent (current-indentation)))))
|
|
220
|
-
;; This was not a closing tag, so we check if the previous line
|
|
221
|
-
;; was an opening tag.
|
|
222
|
-
(save-excursion
|
|
223
|
-
;; Keep moving back until we find a line that is not blank
|
|
224
|
-
(while (progn
|
|
225
|
-
(forward-line -1)
|
|
226
|
-
(and (not (bobp)) (looking-at tpl-mode-blank-line))))
|
|
227
|
-
(setq cur-indent (current-indentation))
|
|
228
|
-
(if (re-search-forward tpl-mode-dangling-open old-pnt t)
|
|
229
|
-
(setq cur-indent (+ cur-indent tpl-basic-offset)))))
|
|
230
|
-
;; Finally, we execute the actual indentation.
|
|
231
|
-
(if (> cur-indent 0)
|
|
232
|
-
(indent-line-to cur-indent)
|
|
233
|
-
(indent-line-to 0))))))
|
|
234
|
-
|
|
235
|
-
;; controls highlighting
|
|
236
|
-
(defconst tpl-mode-font-lock-keywords
|
|
237
|
-
(list
|
|
238
|
-
(list tpl-mode-section
|
|
239
|
-
'(1 font-lock-keyword-face))
|
|
240
|
-
(list tpl-mode-comment
|
|
241
|
-
'(1 font-lock-comment-face))
|
|
242
|
-
(list tpl-mode-include
|
|
243
|
-
'(1 font-lock-builtin-face))
|
|
244
|
-
(list tpl-mode-builtins
|
|
245
|
-
'(1 font-lock-variable-name-face))
|
|
246
|
-
(list tpl-mode-variable
|
|
247
|
-
'(1 font-lock-reference-face))
|
|
248
|
-
(list (concat "</?\\(" tpl-mode-pair-tag "\\)")
|
|
249
|
-
'(1 font-lock-function-name-face))
|
|
250
|
-
(list (concat "<\\(" tpl-mode-standalone-tag "\\)")
|
|
251
|
-
'(1 font-lock-function-name-face))
|
|
252
|
-
(list tpl-mode-html-constant
|
|
253
|
-
'(1 font-lock-variable-name-face))))
|
|
254
|
-
|
|
255
|
-
(put 'tpl-mode 'font-lock-defaults '(tpl-font-lock-keywords nil t))
|
|
256
|
-
|
|
257
|
-
(defun tpl-mode ()
|
|
258
|
-
"Major mode for editing Google CTemplate file."
|
|
259
|
-
(interactive)
|
|
260
|
-
(kill-all-local-variables)
|
|
261
|
-
(use-local-map tpl-mode-map)
|
|
262
|
-
(setq major-mode 'tpl-mode)
|
|
263
|
-
(setq mode-name "tpl-mode")
|
|
264
|
-
(setq local-abbrev-table tpl-mode-abbrev-table)
|
|
265
|
-
(setq indent-tabs-mode nil)
|
|
266
|
-
(set-syntax-table tpl-mode-syntax-table)
|
|
267
|
-
;; show trailing whitespace, but only when the user can fix it
|
|
268
|
-
(setq show-trailing-whitespace (not buffer-read-only))
|
|
269
|
-
(make-local-variable 'indent-line-function)
|
|
270
|
-
(setq indent-line-function 'tpl-indent)
|
|
271
|
-
(setq font-lock-defaults '(tpl-mode-font-lock-keywords))
|
|
272
|
-
(run-hooks 'tpl-mode-hook))
|
|
273
|
-
|
|
274
|
-
(provide 'tpl-mode)
|
data/examples/comments.mustache
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<h1>{{title}}{{! just something interesting... #or not... }}</h1>
|
data/examples/comments.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<h1>{{header}}</h1>
|
|
2
|
-
{{#list}}
|
|
3
|
-
<ul>
|
|
4
|
-
{{#item}}
|
|
5
|
-
{{#current}}
|
|
6
|
-
<li><strong>{{name}}</strong></li>
|
|
7
|
-
{{/current}}
|
|
8
|
-
{{#link}}
|
|
9
|
-
<li><a href="{{url}}">{{name}}</a></li>
|
|
10
|
-
{{/link}}
|
|
11
|
-
{{/item}}
|
|
12
|
-
</ul>
|
|
13
|
-
{{/list}}
|
|
14
|
-
{{#empty}}
|
|
15
|
-
<p>The list is empty.</p>
|
|
16
|
-
{{/empty}}
|
data/examples/complex_view.rb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
|
-
require 'mustache'
|
|
3
|
-
|
|
4
|
-
class ComplexView < Mustache
|
|
5
|
-
self.path = File.dirname(__FILE__)
|
|
6
|
-
|
|
7
|
-
def header
|
|
8
|
-
"Colors"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def item
|
|
12
|
-
items = []
|
|
13
|
-
items << { :name => 'red', :current => true, :url => '#Red' }
|
|
14
|
-
items << { :name => 'green', :current => false, :url => '#Green' }
|
|
15
|
-
items << { :name => 'blue', :current => false, :url => '#Blue' }
|
|
16
|
-
items
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def link
|
|
20
|
-
not context[:current]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def list
|
|
24
|
-
not item.empty?
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def empty
|
|
28
|
-
item.empty?
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
if $0 == __FILE__
|
|
33
|
-
puts ComplexView.to_html
|
|
34
|
-
end
|
data/examples/delimiters.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
|
-
require 'mustache'
|
|
3
|
-
|
|
4
|
-
class Delimiters < Mustache
|
|
5
|
-
self.path = File.dirname(__FILE__)
|
|
6
|
-
|
|
7
|
-
def first
|
|
8
|
-
"It worked the first time."
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def second
|
|
12
|
-
"And it worked the second time."
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def third
|
|
16
|
-
"Then, surprisingly, it worked the third time."
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
if $0 == __FILE__
|
|
21
|
-
puts Delimiters.to_html
|
|
22
|
-
end
|
data/examples/double_section.rb
DELETED
data/examples/escaped.mustache
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<h1>{{title}}</h1>
|
data/examples/escaped.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Again, {{title}}!
|
data/examples/inner_partial.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
## Again, {{title}}! ##
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<h1>{{title}}</h1>
|
data/examples/namespaced.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
|
-
require 'mustache'
|
|
3
|
-
|
|
4
|
-
module TestViews
|
|
5
|
-
class Namespaced < Mustache
|
|
6
|
-
self.path = File.dirname(__FILE__)
|
|
7
|
-
|
|
8
|
-
def title
|
|
9
|
-
"Dragon < Tiger"
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
class NamespacedWithPartial < Mustache
|
|
14
|
-
self.path = File.dirname(__FILE__)
|
|
15
|
-
self.template = "My opinion: {{>inner_partial}}"
|
|
16
|
-
|
|
17
|
-
def title
|
|
18
|
-
"Victory"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
if $0 == __FILE__
|
|
24
|
-
puts TestViews::Namespaced.to_html
|
|
25
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
|
-
require 'mustache'
|
|
3
|
-
|
|
4
|
-
module SimpleView
|
|
5
|
-
def name
|
|
6
|
-
"Bob"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def value
|
|
10
|
-
100_000
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def taxed_value
|
|
14
|
-
value - (value * 0.4)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def in_ca
|
|
18
|
-
false
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
class PartialWithModule < Mustache
|
|
23
|
-
include SimpleView
|
|
24
|
-
self.path = File.dirname(__FILE__)
|
|
25
|
-
|
|
26
|
-
def greeting
|
|
27
|
-
"Welcome"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def farewell
|
|
31
|
-
"Fair enough, right?"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
if $0 == __FILE__
|
|
36
|
-
puts PartialWithModule.to_html
|
|
37
|
-
end
|
data/examples/passenger.conf
DELETED
data/examples/passenger.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
|
-
require 'mustache'
|
|
3
|
-
|
|
4
|
-
class Passenger < Mustache
|
|
5
|
-
self.path = File.dirname(__FILE__)
|
|
6
|
-
self.template_extension = 'conf'
|
|
7
|
-
|
|
8
|
-
def server
|
|
9
|
-
"example.com"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def deploy_to
|
|
13
|
-
"/var/www/example.com"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def stage
|
|
17
|
-
"production"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def timestamp
|
|
21
|
-
Time.now.strftime('%Y%m%d%H%M%S')
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
if $0 == __FILE__
|
|
26
|
-
puts Passenger.to_text
|
|
27
|
-
end
|
data/examples/simple.mustache
DELETED
data/examples/simple.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
|
-
require 'mustache'
|
|
3
|
-
|
|
4
|
-
class Simple < Mustache
|
|
5
|
-
self.path = File.dirname(__FILE__)
|
|
6
|
-
|
|
7
|
-
def name
|
|
8
|
-
"Chris"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def value
|
|
12
|
-
10_000
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def taxed_value
|
|
16
|
-
value - (value * 0.4)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def in_ca
|
|
20
|
-
true
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
if $0 == __FILE__
|
|
25
|
-
puts Simple.to_html
|
|
26
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
|
-
require 'mustache'
|
|
3
|
-
|
|
4
|
-
class TemplatePartial < Mustache
|
|
5
|
-
self.path = File.dirname(__FILE__)
|
|
6
|
-
|
|
7
|
-
def title
|
|
8
|
-
"Welcome"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def title_bars
|
|
12
|
-
'-' * title.size
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
if $0 == __FILE__
|
|
17
|
-
puts TemplatePartial.to_html
|
|
18
|
-
end
|
data/examples/unescaped.mustache
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<h1>{{{title}}}</h1>
|