From 8d93eee40c170b90f35c5eba7623bbc081dc0122 Mon Sep 17 00:00:00 2001 From: Sahab Yazdani Date: Mon, 25 Apr 2011 12:54:03 -0400 Subject: [PATCH] Remove examples since I do not maintain them. Update markdown files and license. --- CHANGES.md | 9 +- LICENSE | 1 + README.md | 16 +- examples/apostrophe.html | 1 - examples/apostrophe.js | 1 - examples/apostrophe.txt | 1 - .../array_of_partials_implicit_partial.2.html | 1 - .../array_of_partials_implicit_partial.html | 4 - .../array_of_partials_implicit_partial.js | 3 - .../array_of_partials_implicit_partial.txt | 5 - examples/array_of_partials_partial.2.html | 1 - examples/array_of_partials_partial.html | 4 - examples/array_of_partials_partial.js | 3 - examples/array_of_partials_partial.txt | 5 - examples/array_of_strings.html | 1 - examples/array_of_strings.js | 1 - examples/array_of_strings.txt | 1 - examples/array_of_strings_options.html | 2 - examples/array_of_strings_options.js | 1 - examples/array_of_strings_options.txt | 1 - examples/array_partial.2.html | 4 - examples/array_partial.html | 1 - examples/array_partial.js | 5 - examples/array_partial.txt | 6 - examples/bug_11_eating_whitespace.html | 1 - examples/bug_11_eating_whitespace.js | 3 - examples/bug_11_eating_whitespace.txt | 1 - examples/bug_46_set_delimiter.html | 5 - examples/bug_46_set_delimiter.js | 3 - examples/bug_46_set_delimiter.txt | 1 - examples/comments.html | 1 - examples/comments.js | 5 - examples/comments.txt | 1 - examples/complex.html | 16 -- examples/complex.js | 19 --- examples/complex.txt | 6 - examples/delimiters.html | 7 - examples/delimiters.js | 6 - examples/delimiters.partial.txt | 2 - examples/delimiters.txt | 5 - examples/delimiters_partial.2.html | 3 - examples/delimiters_partial.html | 3 - examples/delimiters_partial.js | 3 - examples/empty_partial.2.html | 1 - examples/empty_partial.html | 2 - examples/empty_partial.js | 3 - examples/empty_partial.txt | 2 - examples/empty_template.html | 1 - examples/empty_template.js | 1 - examples/empty_template.txt | 1 - examples/error_not_found.html | 1 - examples/error_not_found.js | 1 - examples/error_not_found.txt | 1 - examples/escaped.html | 2 - examples/escaped.js | 6 - examples/escaped.txt | 2 - examples/higher_order_sections.html | 1 - examples/higher_order_sections.js | 9 - examples/higher_order_sections.txt | 1 - examples/inverted_section.html | 2 - examples/inverted_section.js | 3 - examples/inverted_section.txt | 1 - examples/nesting.html | 5 - examples/nesting.js | 7 - examples/nesting.txt | 4 - examples/null_string.html | 5 - examples/null_string.js | 9 - examples/null_string.txt | 5 - examples/partial_recursion.2.html | 4 - examples/partial_recursion.html | 4 - examples/partial_recursion.js | 11 -- examples/partial_recursion.txt | 3 - examples/recursion_with_same_names.html | 7 - examples/recursion_with_same_names.js | 8 - examples/recursion_with_same_names.txt | 6 - examples/reuse_of_enumerables.html | 8 - examples/reuse_of_enumerables.js | 6 - examples/reuse_of_enumerables.txt | 8 - examples/section_as_context.html | 9 - examples/section_as_context.js | 7 - examples/section_as_context.txt | 6 - examples/simple.html | 5 - examples/simple.js | 8 - examples/simple.txt | 3 - examples/template_partial.2.html | 1 - examples/template_partial.html | 2 - examples/template_partial.js | 8 - examples/template_partial.txt | 2 - examples/two_in_a_row.html | 1 - examples/two_in_a_row.js | 4 - examples/two_in_a_row.txt | 1 - examples/unescaped.html | 1 - examples/unescaped.js | 5 - examples/unescaped.txt | 1 - examples/unescaped_ampersand.html | 1 - examples/unescaped_ampersand.js | 5 - examples/unescaped_ampersand.txt | 1 - examples/unknown_pragma.html | 1 - examples/unknown_pragma.js | 1 - examples/unknown_pragma.txt | 1 - examples/view_partial.2.html | 5 - examples/view_partial.html | 3 - examples/view_partial.js | 19 --- examples/view_partial.txt | 6 - examples/whitespace_partial.2.html | 5 - examples/whitespace_partial.html | 3 - examples/whitespace_partial.js | 19 --- examples/whitespace_partial.txt | 6 - mustache.js | 3 + test/mustache_spec.rb | 156 ------------------ 110 files changed, 23 insertions(+), 586 deletions(-) delete mode 100644 examples/apostrophe.html delete mode 100644 examples/apostrophe.js delete mode 100644 examples/apostrophe.txt delete mode 100644 examples/array_of_partials_implicit_partial.2.html delete mode 100644 examples/array_of_partials_implicit_partial.html delete mode 100644 examples/array_of_partials_implicit_partial.js delete mode 100644 examples/array_of_partials_implicit_partial.txt delete mode 100644 examples/array_of_partials_partial.2.html delete mode 100644 examples/array_of_partials_partial.html delete mode 100644 examples/array_of_partials_partial.js delete mode 100644 examples/array_of_partials_partial.txt delete mode 100644 examples/array_of_strings.html delete mode 100644 examples/array_of_strings.js delete mode 100644 examples/array_of_strings.txt delete mode 100644 examples/array_of_strings_options.html delete mode 100644 examples/array_of_strings_options.js delete mode 100644 examples/array_of_strings_options.txt delete mode 100644 examples/array_partial.2.html delete mode 100644 examples/array_partial.html delete mode 100644 examples/array_partial.js delete mode 100644 examples/array_partial.txt delete mode 100644 examples/bug_11_eating_whitespace.html delete mode 100644 examples/bug_11_eating_whitespace.js delete mode 100644 examples/bug_11_eating_whitespace.txt delete mode 100644 examples/bug_46_set_delimiter.html delete mode 100644 examples/bug_46_set_delimiter.js delete mode 100644 examples/bug_46_set_delimiter.txt delete mode 100644 examples/comments.html delete mode 100644 examples/comments.js delete mode 100644 examples/comments.txt delete mode 100644 examples/complex.html delete mode 100644 examples/complex.js delete mode 100644 examples/complex.txt delete mode 100644 examples/delimiters.html delete mode 100644 examples/delimiters.js delete mode 100644 examples/delimiters.partial.txt delete mode 100644 examples/delimiters.txt delete mode 100644 examples/delimiters_partial.2.html delete mode 100644 examples/delimiters_partial.html delete mode 100644 examples/delimiters_partial.js delete mode 100644 examples/empty_partial.2.html delete mode 100644 examples/empty_partial.html delete mode 100644 examples/empty_partial.js delete mode 100644 examples/empty_partial.txt delete mode 100644 examples/empty_template.html delete mode 100644 examples/empty_template.js delete mode 100644 examples/empty_template.txt delete mode 100644 examples/error_not_found.html delete mode 100644 examples/error_not_found.js delete mode 100644 examples/error_not_found.txt delete mode 100644 examples/escaped.html delete mode 100644 examples/escaped.js delete mode 100644 examples/escaped.txt delete mode 100644 examples/higher_order_sections.html delete mode 100644 examples/higher_order_sections.js delete mode 100644 examples/higher_order_sections.txt delete mode 100644 examples/inverted_section.html delete mode 100644 examples/inverted_section.js delete mode 100644 examples/inverted_section.txt delete mode 100644 examples/nesting.html delete mode 100644 examples/nesting.js delete mode 100644 examples/nesting.txt delete mode 100644 examples/null_string.html delete mode 100644 examples/null_string.js delete mode 100644 examples/null_string.txt delete mode 100644 examples/partial_recursion.2.html delete mode 100644 examples/partial_recursion.html delete mode 100644 examples/partial_recursion.js delete mode 100644 examples/partial_recursion.txt delete mode 100644 examples/recursion_with_same_names.html delete mode 100644 examples/recursion_with_same_names.js delete mode 100644 examples/recursion_with_same_names.txt delete mode 100644 examples/reuse_of_enumerables.html delete mode 100644 examples/reuse_of_enumerables.js delete mode 100644 examples/reuse_of_enumerables.txt delete mode 100644 examples/section_as_context.html delete mode 100644 examples/section_as_context.js delete mode 100644 examples/section_as_context.txt delete mode 100644 examples/simple.html delete mode 100644 examples/simple.js delete mode 100644 examples/simple.txt delete mode 100644 examples/template_partial.2.html delete mode 100644 examples/template_partial.html delete mode 100644 examples/template_partial.js delete mode 100644 examples/template_partial.txt delete mode 100644 examples/two_in_a_row.html delete mode 100644 examples/two_in_a_row.js delete mode 100644 examples/two_in_a_row.txt delete mode 100644 examples/unescaped.html delete mode 100644 examples/unescaped.js delete mode 100644 examples/unescaped.txt delete mode 100644 examples/unescaped_ampersand.html delete mode 100644 examples/unescaped_ampersand.js delete mode 100644 examples/unescaped_ampersand.txt delete mode 100644 examples/unknown_pragma.html delete mode 100644 examples/unknown_pragma.js delete mode 100644 examples/unknown_pragma.txt delete mode 100644 examples/view_partial.2.html delete mode 100644 examples/view_partial.html delete mode 100644 examples/view_partial.js delete mode 100644 examples/view_partial.txt delete mode 100644 examples/whitespace_partial.2.html delete mode 100644 examples/whitespace_partial.html delete mode 100644 examples/whitespace_partial.js delete mode 100644 examples/whitespace_partial.txt delete mode 100644 test/mustache_spec.rb diff --git a/CHANGES.md b/CHANGES.md index 61cde5a..b67b8ae 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,13 @@ # mustache.js Changes -## 0.3.1 (??-??-????) +## 0.4.0-vcs + +* Added Compiled Template support +* Correct Set Delimiter implementation +* Implements & unescaping character +* Multiline Comments +* Syntactically Important Whitespace (Issues 25, 41, 48, and 67) +* QUnit unit tests ## 0.3.0 (21-07-2010) diff --git a/LICENSE b/LICENSE index e9f38ab..54f6f1b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,6 @@ Copyright (c) 2009 Chris Wanstrath (Ruby) Copyright (c) 2010 Jan Lehnardt (JavaScript) +Copyright (c) 2011 Vastardis Capital Services (Compiler) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index b013dd6..5360351 100644 --- a/README.md +++ b/README.md @@ -256,6 +256,17 @@ own iteration marker: {{bob}} {{/foo}} +## Template Compiler + +This implementation of Mustache compiles all templates into JavaScript before +execution. This speeds up the conversion of templates into markup when the +template contains lots of sections or deeply nested constructs. Furthermore, +if you are running the same template multiple times, you can retrieve a handle +to the compiled Javascript function using the following code block: + + var template = Mustache.compile('{{>foo}}{{#bar}} had a bar.{{/bar}}', { foo: 'Snow White' }); + var html = template({bar:true}); + ## F.A.Q. ### Why doesn’t Mustache allow dot notation like `{{variable.member}}`? @@ -265,11 +276,6 @@ bugtracker](http://github.com/defunkt/mustache/issues/issue/6). Mustache implementations strive to be template-compatible. - -## More Examples and Documentation - -See `examples/` for more goodies and read the [original mustache docs][m] - ## Command Line See `mustache(1)` man page or diff --git a/examples/apostrophe.html b/examples/apostrophe.html deleted file mode 100644 index e8687aa..0000000 --- a/examples/apostrophe.html +++ /dev/null @@ -1 +0,0 @@ -{{apos}}{{control}} diff --git a/examples/apostrophe.js b/examples/apostrophe.js deleted file mode 100644 index df69cd2..0000000 --- a/examples/apostrophe.js +++ /dev/null @@ -1 +0,0 @@ -var apostrophe = {'apos': "'", 'control':'X'}; diff --git a/examples/apostrophe.txt b/examples/apostrophe.txt deleted file mode 100644 index 4427c30..0000000 --- a/examples/apostrophe.txt +++ /dev/null @@ -1 +0,0 @@ -'X diff --git a/examples/array_of_partials_implicit_partial.2.html b/examples/array_of_partials_implicit_partial.2.html deleted file mode 100644 index 12f7159..0000000 --- a/examples/array_of_partials_implicit_partial.2.html +++ /dev/null @@ -1 +0,0 @@ -{{.}} diff --git a/examples/array_of_partials_implicit_partial.html b/examples/array_of_partials_implicit_partial.html deleted file mode 100644 index 1af6d68..0000000 --- a/examples/array_of_partials_implicit_partial.html +++ /dev/null @@ -1,4 +0,0 @@ -Here is some stuff! -{{#numbers}} -{{>partial}} -{{/numbers}} diff --git a/examples/array_of_partials_implicit_partial.js b/examples/array_of_partials_implicit_partial.js deleted file mode 100644 index fcdf3b0..0000000 --- a/examples/array_of_partials_implicit_partial.js +++ /dev/null @@ -1,3 +0,0 @@ -var partial_context = { - numbers: ['1', '2', '3', '4'] -}; diff --git a/examples/array_of_partials_implicit_partial.txt b/examples/array_of_partials_implicit_partial.txt deleted file mode 100644 index f622375..0000000 --- a/examples/array_of_partials_implicit_partial.txt +++ /dev/null @@ -1,5 +0,0 @@ -Here is some stuff! -1 -2 -3 -4 diff --git a/examples/array_of_partials_partial.2.html b/examples/array_of_partials_partial.2.html deleted file mode 100644 index bdde77d..0000000 --- a/examples/array_of_partials_partial.2.html +++ /dev/null @@ -1 +0,0 @@ -{{i}} diff --git a/examples/array_of_partials_partial.html b/examples/array_of_partials_partial.html deleted file mode 100644 index 1af6d68..0000000 --- a/examples/array_of_partials_partial.html +++ /dev/null @@ -1,4 +0,0 @@ -Here is some stuff! -{{#numbers}} -{{>partial}} -{{/numbers}} diff --git a/examples/array_of_partials_partial.js b/examples/array_of_partials_partial.js deleted file mode 100644 index 45611cf..0000000 --- a/examples/array_of_partials_partial.js +++ /dev/null @@ -1,3 +0,0 @@ -var partial_context = { - numbers: [{i: '1'}, {i: '2'}, {i: '3'}, {i: '4'}] -}; diff --git a/examples/array_of_partials_partial.txt b/examples/array_of_partials_partial.txt deleted file mode 100644 index f622375..0000000 --- a/examples/array_of_partials_partial.txt +++ /dev/null @@ -1,5 +0,0 @@ -Here is some stuff! -1 -2 -3 -4 diff --git a/examples/array_of_strings.html b/examples/array_of_strings.html deleted file mode 100644 index 2898705..0000000 --- a/examples/array_of_strings.html +++ /dev/null @@ -1 +0,0 @@ -{{#array_of_strings}}{{.}} {{/array_of_strings}} \ No newline at end of file diff --git a/examples/array_of_strings.js b/examples/array_of_strings.js deleted file mode 100644 index 12c4992..0000000 --- a/examples/array_of_strings.js +++ /dev/null @@ -1 +0,0 @@ -var array_of_strings = {array_of_strings: ['hello', 'world']}; diff --git a/examples/array_of_strings.txt b/examples/array_of_strings.txt deleted file mode 100644 index 4a1f475..0000000 --- a/examples/array_of_strings.txt +++ /dev/null @@ -1 +0,0 @@ -hello world diff --git a/examples/array_of_strings_options.html b/examples/array_of_strings_options.html deleted file mode 100644 index 6b28278..0000000 --- a/examples/array_of_strings_options.html +++ /dev/null @@ -1,2 +0,0 @@ -{{%IMPLICIT-ITERATOR iterator=rob}} -{{#array_of_strings_options}}{{rob}} {{/array_of_strings_options}} \ No newline at end of file diff --git a/examples/array_of_strings_options.js b/examples/array_of_strings_options.js deleted file mode 100644 index 2e29adf..0000000 --- a/examples/array_of_strings_options.js +++ /dev/null @@ -1 +0,0 @@ -var array_of_strings_options = {array_of_strings_options: ['hello', 'world']}; diff --git a/examples/array_of_strings_options.txt b/examples/array_of_strings_options.txt deleted file mode 100644 index 4a1f475..0000000 --- a/examples/array_of_strings_options.txt +++ /dev/null @@ -1 +0,0 @@ -hello world diff --git a/examples/array_partial.2.html b/examples/array_partial.2.html deleted file mode 100644 index 235dd5f..0000000 --- a/examples/array_partial.2.html +++ /dev/null @@ -1,4 +0,0 @@ -Here's a non-sense array of values -{{#array}} - {{.}} -{{/array}} \ No newline at end of file diff --git a/examples/array_partial.html b/examples/array_partial.html deleted file mode 100644 index 7a336fe..0000000 --- a/examples/array_partial.html +++ /dev/null @@ -1 +0,0 @@ -{{>partial}} \ No newline at end of file diff --git a/examples/array_partial.js b/examples/array_partial.js deleted file mode 100644 index 88d7592..0000000 --- a/examples/array_partial.js +++ /dev/null @@ -1,5 +0,0 @@ -var partial_context = { - partial: { - array: ['1', '2', '3', '4'] - } -}; \ No newline at end of file diff --git a/examples/array_partial.txt b/examples/array_partial.txt deleted file mode 100644 index fd5f48e..0000000 --- a/examples/array_partial.txt +++ /dev/null @@ -1,6 +0,0 @@ -Here's a non-sense array of values - 1 - 2 - 3 - 4 - diff --git a/examples/bug_11_eating_whitespace.html b/examples/bug_11_eating_whitespace.html deleted file mode 100644 index 8d5cd92..0000000 --- a/examples/bug_11_eating_whitespace.html +++ /dev/null @@ -1 +0,0 @@ -{{tag}} foo diff --git a/examples/bug_11_eating_whitespace.js b/examples/bug_11_eating_whitespace.js deleted file mode 100644 index 78ce975..0000000 --- a/examples/bug_11_eating_whitespace.js +++ /dev/null @@ -1,3 +0,0 @@ -var bug_11_eating_whitespace = { - tag: "yo" -}; diff --git a/examples/bug_11_eating_whitespace.txt b/examples/bug_11_eating_whitespace.txt deleted file mode 100644 index f5bbc85..0000000 --- a/examples/bug_11_eating_whitespace.txt +++ /dev/null @@ -1 +0,0 @@ -yo foo diff --git a/examples/bug_46_set_delimiter.html b/examples/bug_46_set_delimiter.html deleted file mode 100644 index a2073aa..0000000 --- a/examples/bug_46_set_delimiter.html +++ /dev/null @@ -1,5 +0,0 @@ -{{=[[ ]]=}} -[[#IsMustacheAwesome]] -mustache is awesome. -[[/IsMustacheAwesome]] -[[={{ }}=]] \ No newline at end of file diff --git a/examples/bug_46_set_delimiter.js b/examples/bug_46_set_delimiter.js deleted file mode 100644 index ba0d954..0000000 --- a/examples/bug_46_set_delimiter.js +++ /dev/null @@ -1,3 +0,0 @@ -var bug_46_set_delimiter = { - IsMustacheAwesome: true -}; diff --git a/examples/bug_46_set_delimiter.txt b/examples/bug_46_set_delimiter.txt deleted file mode 100644 index 54c4f44..0000000 --- a/examples/bug_46_set_delimiter.txt +++ /dev/null @@ -1 +0,0 @@ -mustache is awesome. \ No newline at end of file diff --git a/examples/comments.html b/examples/comments.html deleted file mode 100644 index 0a0ae49..0000000 --- a/examples/comments.html +++ /dev/null @@ -1 +0,0 @@ -

{{title}}{{! just something interesting... or not... !}}

diff --git a/examples/comments.js b/examples/comments.js deleted file mode 100644 index f85f979..0000000 --- a/examples/comments.js +++ /dev/null @@ -1,5 +0,0 @@ -var comments = { - title: function() { - return "A Comedy of Errors"; - } -}; diff --git a/examples/comments.txt b/examples/comments.txt deleted file mode 100644 index 0133517..0000000 --- a/examples/comments.txt +++ /dev/null @@ -1 +0,0 @@ -

A Comedy of Errors

diff --git a/examples/complex.html b/examples/complex.html deleted file mode 100644 index 23bec3c..0000000 --- a/examples/complex.html +++ /dev/null @@ -1,16 +0,0 @@ -

{{header}}

-{{#list}} - -{{/list}} -{{#empty}} -

The list is empty.

-{{/empty}} \ No newline at end of file diff --git a/examples/complex.js b/examples/complex.js deleted file mode 100644 index a0dfb63..0000000 --- a/examples/complex.js +++ /dev/null @@ -1,19 +0,0 @@ -var complex = { - header: function() { - return "Colors"; - }, - item: [ - {name: "red", current: true, url: "#Red"}, - {name: "green", current: false, url: "#Green"}, - {name: "blue", current: false, url: "#Blue"} - ], - link: function() { - return this["current"] !== true; - }, - list: function() { - return this.item.length !== 0; - }, - empty: function() { - return this.item.length === 0; - } -}; diff --git a/examples/complex.txt b/examples/complex.txt deleted file mode 100644 index b51ca10..0000000 --- a/examples/complex.txt +++ /dev/null @@ -1,6 +0,0 @@ -

Colors

- diff --git a/examples/delimiters.html b/examples/delimiters.html deleted file mode 100644 index a73e061..0000000 --- a/examples/delimiters.html +++ /dev/null @@ -1,7 +0,0 @@ -{{=<% %>=}}* -<% first %> -* <% second %> -<%=| |=%> -* | third | -|={{ }}=| -* {{ fourth }} \ No newline at end of file diff --git a/examples/delimiters.js b/examples/delimiters.js deleted file mode 100644 index 220d0d2..0000000 --- a/examples/delimiters.js +++ /dev/null @@ -1,6 +0,0 @@ -var delimiters = { - first: "It worked the first time.", - second: "And it worked the second time.", - third: "Then, surprisingly, it worked the third time.", - fourth: "Fourth time also fine!." -} diff --git a/examples/delimiters.partial.txt b/examples/delimiters.partial.txt deleted file mode 100644 index 04b2c1c..0000000 --- a/examples/delimiters.partial.txt +++ /dev/null @@ -1,2 +0,0 @@ -{{text}} -{{text}} \ No newline at end of file diff --git a/examples/delimiters.txt b/examples/delimiters.txt deleted file mode 100644 index 698a6bb..0000000 --- a/examples/delimiters.txt +++ /dev/null @@ -1,5 +0,0 @@ -* -It worked the first time. -* And it worked the second time. -* Then, surprisingly, it worked the third time. -* Fourth time also fine!. diff --git a/examples/delimiters_partial.2.html b/examples/delimiters_partial.2.html deleted file mode 100644 index ca128df..0000000 --- a/examples/delimiters_partial.2.html +++ /dev/null @@ -1,3 +0,0 @@ -{{=[[ ]]=}} -{{text}} -[[={{ }}=]] \ No newline at end of file diff --git a/examples/delimiters_partial.html b/examples/delimiters_partial.html deleted file mode 100644 index 8fe568c..0000000 --- a/examples/delimiters_partial.html +++ /dev/null @@ -1,3 +0,0 @@ -{{#enumerate}} -{{>partial}} -{{/enumerate}} \ No newline at end of file diff --git a/examples/delimiters_partial.js b/examples/delimiters_partial.js deleted file mode 100644 index d82e7d7..0000000 --- a/examples/delimiters_partial.js +++ /dev/null @@ -1,3 +0,0 @@ -var partial_context = { - enumerate: [ {text: 'A'}, {text: 'B'} ] -} diff --git a/examples/empty_partial.2.html b/examples/empty_partial.2.html deleted file mode 100644 index b920295..0000000 --- a/examples/empty_partial.2.html +++ /dev/null @@ -1 +0,0 @@ -yo \ No newline at end of file diff --git a/examples/empty_partial.html b/examples/empty_partial.html deleted file mode 100644 index a710047..0000000 --- a/examples/empty_partial.html +++ /dev/null @@ -1,2 +0,0 @@ -hey {{foo}} -{{>partial}} diff --git a/examples/empty_partial.js b/examples/empty_partial.js deleted file mode 100644 index 9cc53c6..0000000 --- a/examples/empty_partial.js +++ /dev/null @@ -1,3 +0,0 @@ -var partial_context = { - foo: 1 -}; diff --git a/examples/empty_partial.txt b/examples/empty_partial.txt deleted file mode 100644 index 90d2b9f..0000000 --- a/examples/empty_partial.txt +++ /dev/null @@ -1,2 +0,0 @@ -hey 1 -yo diff --git a/examples/empty_template.html b/examples/empty_template.html deleted file mode 100644 index bb2367a..0000000 --- a/examples/empty_template.html +++ /dev/null @@ -1 +0,0 @@ -

Test

\ No newline at end of file diff --git a/examples/empty_template.js b/examples/empty_template.js deleted file mode 100644 index 564c9e2..0000000 --- a/examples/empty_template.js +++ /dev/null @@ -1 +0,0 @@ -var empty_template = {}; diff --git a/examples/empty_template.txt b/examples/empty_template.txt deleted file mode 100644 index 60652b6..0000000 --- a/examples/empty_template.txt +++ /dev/null @@ -1 +0,0 @@ -

Test

diff --git a/examples/error_not_found.html b/examples/error_not_found.html deleted file mode 100644 index 24369f7..0000000 --- a/examples/error_not_found.html +++ /dev/null @@ -1 +0,0 @@ -{{foo}} \ No newline at end of file diff --git a/examples/error_not_found.js b/examples/error_not_found.js deleted file mode 100644 index 6cdbdb3..0000000 --- a/examples/error_not_found.js +++ /dev/null @@ -1 +0,0 @@ -var error_not_found = {bar: 2}; \ No newline at end of file diff --git a/examples/error_not_found.txt b/examples/error_not_found.txt deleted file mode 100644 index 8b13789..0000000 --- a/examples/error_not_found.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/escaped.html b/examples/escaped.html deleted file mode 100644 index ea25951..0000000 --- a/examples/escaped.html +++ /dev/null @@ -1,2 +0,0 @@ -

{{title}}

-But not {{entities}}. diff --git a/examples/escaped.js b/examples/escaped.js deleted file mode 100644 index 7a8baef..0000000 --- a/examples/escaped.js +++ /dev/null @@ -1,6 +0,0 @@ -var escaped = { - title: function() { - return "Bear > Shark"; - }, - entities: """ -}; diff --git a/examples/escaped.txt b/examples/escaped.txt deleted file mode 100644 index 73ac5ce..0000000 --- a/examples/escaped.txt +++ /dev/null @@ -1,2 +0,0 @@ -

Bear > Shark

-But not ". diff --git a/examples/higher_order_sections.html b/examples/higher_order_sections.html deleted file mode 100644 index 04f5318..0000000 --- a/examples/higher_order_sections.html +++ /dev/null @@ -1 +0,0 @@ -{{#bolder}}Hi {{name}}.{{/bolder}} diff --git a/examples/higher_order_sections.js b/examples/higher_order_sections.js deleted file mode 100644 index c7e558e..0000000 --- a/examples/higher_order_sections.js +++ /dev/null @@ -1,9 +0,0 @@ -var higher_order_sections = { - "name": "Tater", - "helper": "To tinker?", - "bolder": function() { - return function(text, render) { - return "" + render(text) + ' ' + this.helper; - } - } -} \ No newline at end of file diff --git a/examples/higher_order_sections.txt b/examples/higher_order_sections.txt deleted file mode 100644 index 9db786a..0000000 --- a/examples/higher_order_sections.txt +++ /dev/null @@ -1 +0,0 @@ -Hi Tater. To tinker? diff --git a/examples/inverted_section.html b/examples/inverted_section.html deleted file mode 100644 index beec558..0000000 --- a/examples/inverted_section.html +++ /dev/null @@ -1,2 +0,0 @@ -{{#repo}}{{name}}{{/repo}} -{{^repo}}No repos :({{/repo}} diff --git a/examples/inverted_section.js b/examples/inverted_section.js deleted file mode 100644 index cb96ecf..0000000 --- a/examples/inverted_section.js +++ /dev/null @@ -1,3 +0,0 @@ -var inverted_section = { - "repo": [] -} diff --git a/examples/inverted_section.txt b/examples/inverted_section.txt deleted file mode 100644 index 5fd0de1..0000000 --- a/examples/inverted_section.txt +++ /dev/null @@ -1 +0,0 @@ -No repos :( diff --git a/examples/nesting.html b/examples/nesting.html deleted file mode 100644 index 551366d..0000000 --- a/examples/nesting.html +++ /dev/null @@ -1,5 +0,0 @@ -{{#foo}} - {{#a}} - {{b}} - {{/a}} -{{/foo}} diff --git a/examples/nesting.js b/examples/nesting.js deleted file mode 100644 index 1f76cd0..0000000 --- a/examples/nesting.js +++ /dev/null @@ -1,7 +0,0 @@ -var nesting = { - foo: [ - {a: {b: 1}}, - {a: {b: 2}}, - {a: {b: 3}} - ] -}; diff --git a/examples/nesting.txt b/examples/nesting.txt deleted file mode 100644 index caf5afd..0000000 --- a/examples/nesting.txt +++ /dev/null @@ -1,4 +0,0 @@ - 1 - 2 - 3 - diff --git a/examples/null_string.html b/examples/null_string.html deleted file mode 100644 index 12bcb08..0000000 --- a/examples/null_string.html +++ /dev/null @@ -1,5 +0,0 @@ -Hello {{name}} -glytch {{glytch}} -binary {{binary}} -value {{value}} -numeric {{numeric}} \ No newline at end of file diff --git a/examples/null_string.js b/examples/null_string.js deleted file mode 100644 index 93414a1..0000000 --- a/examples/null_string.js +++ /dev/null @@ -1,9 +0,0 @@ -var null_string = { - name: "Elise", - glytch: true, - binary: false, - value: null, - numeric: function() { - return NaN; - } -}; diff --git a/examples/null_string.txt b/examples/null_string.txt deleted file mode 100644 index 827569b..0000000 --- a/examples/null_string.txt +++ /dev/null @@ -1,5 +0,0 @@ -Hello Elise -glytch true -binary false -value -numeric NaN diff --git a/examples/partial_recursion.2.html b/examples/partial_recursion.2.html deleted file mode 100644 index 457d2a0..0000000 --- a/examples/partial_recursion.2.html +++ /dev/null @@ -1,4 +0,0 @@ -{{name}} -{{#children}} -{{>partial}} -{{/children}} \ No newline at end of file diff --git a/examples/partial_recursion.html b/examples/partial_recursion.html deleted file mode 100644 index d965a6a..0000000 --- a/examples/partial_recursion.html +++ /dev/null @@ -1,4 +0,0 @@ -{{name}} -{{#kids}} -{{>partial}} -{{/kids}} \ No newline at end of file diff --git a/examples/partial_recursion.js b/examples/partial_recursion.js deleted file mode 100644 index ad1f2eb..0000000 --- a/examples/partial_recursion.js +++ /dev/null @@ -1,11 +0,0 @@ -var partial_context = { - name: '1', - kids: [ - { - name: '1.1', - children: [ - {name: '1.1.1'} - ] - } - ] -}; diff --git a/examples/partial_recursion.txt b/examples/partial_recursion.txt deleted file mode 100644 index 0f70515..0000000 --- a/examples/partial_recursion.txt +++ /dev/null @@ -1,3 +0,0 @@ -1 -1.1 -1.1.1 diff --git a/examples/recursion_with_same_names.html b/examples/recursion_with_same_names.html deleted file mode 100644 index c331d04..0000000 --- a/examples/recursion_with_same_names.html +++ /dev/null @@ -1,7 +0,0 @@ -{{ name }} -{{ description }} - -{{#terms}} - {{name}} - {{index}} -{{/terms}} diff --git a/examples/recursion_with_same_names.js b/examples/recursion_with_same_names.js deleted file mode 100644 index 5cceb08..0000000 --- a/examples/recursion_with_same_names.js +++ /dev/null @@ -1,8 +0,0 @@ -var recursion_with_same_names = { - name: 'name', - description: 'desc', - terms: [ - {name: 't1', index: 0}, - {name: 't2', index: 1}, - ] -}; \ No newline at end of file diff --git a/examples/recursion_with_same_names.txt b/examples/recursion_with_same_names.txt deleted file mode 100644 index c23bb65..0000000 --- a/examples/recursion_with_same_names.txt +++ /dev/null @@ -1,6 +0,0 @@ -name -desc - t1 - 0 - t2 - 1 diff --git a/examples/reuse_of_enumerables.html b/examples/reuse_of_enumerables.html deleted file mode 100644 index cc0cb7a..0000000 --- a/examples/reuse_of_enumerables.html +++ /dev/null @@ -1,8 +0,0 @@ -{{#terms}} - {{name}} - {{index}} -{{/terms}} -{{#terms}} - {{name}} - {{index}} -{{/terms}} diff --git a/examples/reuse_of_enumerables.js b/examples/reuse_of_enumerables.js deleted file mode 100644 index 543e121..0000000 --- a/examples/reuse_of_enumerables.js +++ /dev/null @@ -1,6 +0,0 @@ -var reuse_of_enumerables = { - terms: [ - {name: 't1', index: 0}, - {name: 't2', index: 1}, - ] -}; \ No newline at end of file diff --git a/examples/reuse_of_enumerables.txt b/examples/reuse_of_enumerables.txt deleted file mode 100644 index 6d05d96..0000000 --- a/examples/reuse_of_enumerables.txt +++ /dev/null @@ -1,8 +0,0 @@ - t1 - 0 - t2 - 1 - t1 - 0 - t2 - 1 diff --git a/examples/section_as_context.html b/examples/section_as_context.html deleted file mode 100644 index 59990f6..0000000 --- a/examples/section_as_context.html +++ /dev/null @@ -1,9 +0,0 @@ -{{#a_object}} -

{{title}}

-

{{description}}

- -{{/a_object}} diff --git a/examples/section_as_context.js b/examples/section_as_context.js deleted file mode 100644 index 81ca1be..0000000 --- a/examples/section_as_context.js +++ /dev/null @@ -1,7 +0,0 @@ -var section_as_context = { - a_object: { - title: 'this is an object', - description: 'one of its attributes is a list', - a_list: [{label: 'listitem1'}, {label: 'listitem2'}] - } -}; diff --git a/examples/section_as_context.txt b/examples/section_as_context.txt deleted file mode 100644 index 53ee336..0000000 --- a/examples/section_as_context.txt +++ /dev/null @@ -1,6 +0,0 @@ -

this is an object

-

one of its attributes is a list

- diff --git a/examples/simple.html b/examples/simple.html deleted file mode 100644 index 03df206..0000000 --- a/examples/simple.html +++ /dev/null @@ -1,5 +0,0 @@ -Hello {{name}} -You have just won ${{value}}! -{{#in_ca}} -Well, ${{ taxed_value }}, after taxes. -{{/in_ca}} \ No newline at end of file diff --git a/examples/simple.js b/examples/simple.js deleted file mode 100644 index 30f9834..0000000 --- a/examples/simple.js +++ /dev/null @@ -1,8 +0,0 @@ -var simple = { - name: "Chris", - value: 10000, - taxed_value: function() { - return this.value - (this.value * 0.4); - }, - in_ca: true -}; diff --git a/examples/simple.txt b/examples/simple.txt deleted file mode 100644 index 5d75d65..0000000 --- a/examples/simple.txt +++ /dev/null @@ -1,3 +0,0 @@ -Hello Chris -You have just won $10000! -Well, $6000, after taxes. diff --git a/examples/template_partial.2.html b/examples/template_partial.2.html deleted file mode 100644 index 54bdd7d..0000000 --- a/examples/template_partial.2.html +++ /dev/null @@ -1 +0,0 @@ -Again, {{again}}! \ No newline at end of file diff --git a/examples/template_partial.html b/examples/template_partial.html deleted file mode 100644 index 6a09372..0000000 --- a/examples/template_partial.html +++ /dev/null @@ -1,2 +0,0 @@ -

{{title}}

-{{>partial}} \ No newline at end of file diff --git a/examples/template_partial.js b/examples/template_partial.js deleted file mode 100644 index 68a4317..0000000 --- a/examples/template_partial.js +++ /dev/null @@ -1,8 +0,0 @@ -var partial_context = { - title: function() { - return "Welcome"; - }, - partial: { - again: "Goodbye" - } -} diff --git a/examples/template_partial.txt b/examples/template_partial.txt deleted file mode 100644 index 692698f..0000000 --- a/examples/template_partial.txt +++ /dev/null @@ -1,2 +0,0 @@ -

Welcome

-Again, Goodbye! diff --git a/examples/two_in_a_row.html b/examples/two_in_a_row.html deleted file mode 100644 index dc38602..0000000 --- a/examples/two_in_a_row.html +++ /dev/null @@ -1 +0,0 @@ -{{greeting}}, {{name}}! \ No newline at end of file diff --git a/examples/two_in_a_row.js b/examples/two_in_a_row.js deleted file mode 100644 index 09c1809..0000000 --- a/examples/two_in_a_row.js +++ /dev/null @@ -1,4 +0,0 @@ -var two_in_a_row = { - name: "Joe", - greeting: "Welcome" -}; diff --git a/examples/two_in_a_row.txt b/examples/two_in_a_row.txt deleted file mode 100644 index c6d6a9b..0000000 --- a/examples/two_in_a_row.txt +++ /dev/null @@ -1 +0,0 @@ -Welcome, Joe! diff --git a/examples/unescaped.html b/examples/unescaped.html deleted file mode 100644 index 9982708..0000000 --- a/examples/unescaped.html +++ /dev/null @@ -1 +0,0 @@ -

{{{title}}}

\ No newline at end of file diff --git a/examples/unescaped.js b/examples/unescaped.js deleted file mode 100644 index 0bd20b8..0000000 --- a/examples/unescaped.js +++ /dev/null @@ -1,5 +0,0 @@ -var unescaped = { - title: function() { - return "Bear > Shark"; - } -}; diff --git a/examples/unescaped.txt b/examples/unescaped.txt deleted file mode 100644 index 089ad79..0000000 --- a/examples/unescaped.txt +++ /dev/null @@ -1 +0,0 @@ -

Bear > Shark

diff --git a/examples/unescaped_ampersand.html b/examples/unescaped_ampersand.html deleted file mode 100644 index 3bccbf9..0000000 --- a/examples/unescaped_ampersand.html +++ /dev/null @@ -1 +0,0 @@ -

{{&title}}

\ No newline at end of file diff --git a/examples/unescaped_ampersand.js b/examples/unescaped_ampersand.js deleted file mode 100644 index 11f30cc..0000000 --- a/examples/unescaped_ampersand.js +++ /dev/null @@ -1,5 +0,0 @@ -var unescaped_ampersand = { - title: function() { - return "Bear > Shark"; - } -}; diff --git a/examples/unescaped_ampersand.txt b/examples/unescaped_ampersand.txt deleted file mode 100644 index 089ad79..0000000 --- a/examples/unescaped_ampersand.txt +++ /dev/null @@ -1 +0,0 @@ -

Bear > Shark

diff --git a/examples/unknown_pragma.html b/examples/unknown_pragma.html deleted file mode 100644 index 113810d..0000000 --- a/examples/unknown_pragma.html +++ /dev/null @@ -1 +0,0 @@ -{{%I-HAVE-THE-GREATEST-MUSTACHE}} diff --git a/examples/unknown_pragma.js b/examples/unknown_pragma.js deleted file mode 100644 index 68344a5..0000000 --- a/examples/unknown_pragma.js +++ /dev/null @@ -1 +0,0 @@ -var unknown_pragma = {}; diff --git a/examples/unknown_pragma.txt b/examples/unknown_pragma.txt deleted file mode 100644 index a34840d..0000000 --- a/examples/unknown_pragma.txt +++ /dev/null @@ -1 +0,0 @@ -ERROR: This implementation of mustache doesn't understand the 'I-HAVE-THE-GREATEST-MUSTACHE' pragma diff --git a/examples/view_partial.2.html b/examples/view_partial.2.html deleted file mode 100644 index 2fea632..0000000 --- a/examples/view_partial.2.html +++ /dev/null @@ -1,5 +0,0 @@ -Hello {{name}} -You have just won ${{value}}! -{{#in_ca}} -Well, ${{ taxed_value }}, after taxes. -{{/in_ca}} diff --git a/examples/view_partial.html b/examples/view_partial.html deleted file mode 100644 index 8f0c08d..0000000 --- a/examples/view_partial.html +++ /dev/null @@ -1,3 +0,0 @@ -

{{greeting}}

-{{>partial}} -

{{farewell}}

\ No newline at end of file diff --git a/examples/view_partial.js b/examples/view_partial.js deleted file mode 100644 index 30ade55..0000000 --- a/examples/view_partial.js +++ /dev/null @@ -1,19 +0,0 @@ -var partial_context = { - greeting: function() { - return "Welcome"; - }, - - farewell: function() { - return "Fair enough, right?"; - }, - - partial: { - name: "Chris", - value: 10000, - taxed_value: function() { - return this.value - (this.value * 0.4); - }, - in_ca: true - } -}; - diff --git a/examples/view_partial.txt b/examples/view_partial.txt deleted file mode 100644 index 160b0b6..0000000 --- a/examples/view_partial.txt +++ /dev/null @@ -1,6 +0,0 @@ -

Welcome

-Hello Chris -You have just won $10000! -Well, $6000, after taxes. - -

Fair enough, right?

diff --git a/examples/whitespace_partial.2.html b/examples/whitespace_partial.2.html deleted file mode 100644 index 9c46084..0000000 --- a/examples/whitespace_partial.2.html +++ /dev/null @@ -1,5 +0,0 @@ -Hello {{ name}} -You have just won ${{value }}! -{{# in_ca }} -Well, ${{ taxed_value }}, after taxes. -{{/ in_ca }} diff --git a/examples/whitespace_partial.html b/examples/whitespace_partial.html deleted file mode 100644 index ce43cb3..0000000 --- a/examples/whitespace_partial.html +++ /dev/null @@ -1,3 +0,0 @@ -

{{ greeting }}

-{{> partial }} -

{{ farewell }}

\ No newline at end of file diff --git a/examples/whitespace_partial.js b/examples/whitespace_partial.js deleted file mode 100644 index 30ade55..0000000 --- a/examples/whitespace_partial.js +++ /dev/null @@ -1,19 +0,0 @@ -var partial_context = { - greeting: function() { - return "Welcome"; - }, - - farewell: function() { - return "Fair enough, right?"; - }, - - partial: { - name: "Chris", - value: 10000, - taxed_value: function() { - return this.value - (this.value * 0.4); - }, - in_ca: true - } -}; - diff --git a/examples/whitespace_partial.txt b/examples/whitespace_partial.txt deleted file mode 100644 index 160b0b6..0000000 --- a/examples/whitespace_partial.txt +++ /dev/null @@ -1,6 +0,0 @@ -

Welcome

-Hello Chris -You have just won $10000! -Well, $6000, after taxes. - -

Fair enough, right?

diff --git a/mustache.js b/mustache.js index 8b52bc1..e36b293 100644 --- a/mustache.js +++ b/mustache.js @@ -2,6 +2,9 @@ mustache.js — Logic-less templates in JavaScript See http://mustache.github.com/ for more info. + + This implementation adds a template compiler for faster processing and fixes bugs. + See http://www.saliences.com/projects/mustache/mustache.html for details. */ var Mustache = function() { diff --git a/test/mustache_spec.rb b/test/mustache_spec.rb deleted file mode 100644 index 9ede6c8..0000000 --- a/test/mustache_spec.rb +++ /dev/null @@ -1,156 +0,0 @@ -require 'rubygems' -require 'json' - -__DIR__ = File.dirname(__FILE__) - -testnames = Dir.glob(__DIR__ + '/../examples/*.js').map do |name| - File.basename name, '.js' -end - -non_partials = testnames.select{|t| not t.include? "partial"} -partials = testnames.select{|t| t.include? "partial"} - -def load_test(dir, name, partial=false) - view = File.read(dir + "/../examples/#{name}.js") - template = File.read(dir + "/../examples/#{name}.html").to_json - expect = File.read(dir + "/../examples/#{name}.txt") - if not partial - [view, template, expect] - else - partial = File.read(dir + "/../examples/#{name}.2.html").to_json - [view, template, partial, expect] - end -end - -describe "mustache" do - before(:all) do - @mustache = File.read(__DIR__ + "/../mustache.js") - end - - it "should return the same when invoked multiple times" do - js = <<-JS - #{@mustache} - Mustache.to_html("x") - print(Mustache.to_html("x")); - JS - run_js(js).should == "x\n" - - end - - it "should clear the context after each run" do - js = <<-JS - #{@mustache} - Mustache.to_html("{{#list}}{{x}}{{/list}}", {list: [{x: 1}]}) - try { - print(Mustache.to_html("{{#list}}{{x}}{{/list}}", {list: [{}]})); - } catch(e) { - print('ERROR: ' + e.message); - } - JS - run_js(js).should == "\n" - end - - non_partials.each do |testname| - describe testname do - it "should generate the correct html" do - - view, template, expect = load_test(__DIR__, testname) - - runner = <<-JS - try { - #{@mustache} - #{view} - var template = #{template}; - var result = Mustache.to_html(template, #{testname}); - print(result); - } catch(e) { - print('ERROR: ' + e.message); - } - JS - - run_js(runner).should == expect - end - it "should sendFun the correct html" do - - view, template, expect = load_test(__DIR__, testname) - - runner = <<-JS - try { - #{@mustache} - #{view} - var chunks = []; - var sendFun = function(chunk) { - if (chunk != "") { - chunks.push(chunk); - } - } - var template = #{template}; - Mustache.to_html(template, #{testname}, null, sendFun); - print(chunks.join("\\n")); - } catch(e) { - print('ERROR: ' + e.message); - } - JS - - run_js(runner).strip.should == expect.strip - end - end - end - - partials.each do |testname| - describe testname do - it "should generate the correct html" do - - view, template, partial, expect = - load_test(__DIR__, testname, true) - - runner = <<-JS - try { - #{@mustache} - #{view} - var template = #{template}; - var partials = {"partial": #{partial}}; - var result = Mustache.to_html(template, partial_context, partials); - print(result); - } catch(e) { - print('ERROR: ' + e.message); - } - JS - - run_js(runner).should == expect - end - it "should sendFun the correct html" do - - view, template, partial, expect = - load_test(__DIR__, testname, true) - - runner = <<-JS - try { - #{@mustache} - #{view}; - var template = #{template}; - var partials = {"partial": #{partial}}; - var chunks = []; - var sendFun = function(chunk) { - if (chunk != "") { - chunks.push(chunk); - } - } - Mustache.to_html(template, partial_context, partials, sendFun); - print(chunks.join("\\n")); - } catch(e) { - print('ERROR: ' + e.message); - } - JS - - run_js(runner).strip.should == expect.strip - end - end - end - - def run_js(js) - File.open("runner.js", 'w') {|f| f << js} - `js runner.js` - end -end -