wlang 0.10.2 → 2.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -121
- data/Gemfile +23 -1
- data/Gemfile.lock +32 -28
- data/LICENCE.md +18 -21
- data/Manifest.txt +4 -5
- data/README.md +100 -174
- data/Rakefile +1 -13
- data/bin/wlang +3 -29
- data/lib/wlang.rb +21 -394
- data/lib/wlang/command.rb +94 -0
- data/lib/wlang/compiler.rb +78 -0
- data/lib/wlang/compiler/autospacing.rb +60 -0
- data/lib/wlang/compiler/dialect_enforcer.rb +91 -0
- data/lib/wlang/compiler/filter.rb +32 -0
- data/lib/wlang/compiler/grammar.citrus +67 -0
- data/lib/wlang/compiler/parser.rb +26 -0
- data/lib/wlang/compiler/proc_call_removal.rb +15 -0
- data/lib/wlang/compiler/static_merger.rb +28 -0
- data/lib/wlang/compiler/strconcat_flattener.rb +25 -0
- data/lib/wlang/compiler/to_ruby_abstraction.rb +22 -0
- data/lib/wlang/compiler/to_ruby_code.rb +55 -0
- data/lib/wlang/dialect.rb +40 -237
- data/lib/wlang/dialect/dispatching.rb +51 -0
- data/lib/wlang/dialect/evaluation.rb +30 -0
- data/lib/wlang/dialect/tags.rb +50 -0
- data/lib/wlang/dummy.rb +32 -0
- data/lib/wlang/html.rb +106 -0
- data/lib/wlang/loader.rb +6 -0
- data/lib/wlang/mustang.rb +90 -0
- data/lib/wlang/scope.rb +57 -0
- data/lib/wlang/scope/binding_scope.rb +18 -0
- data/lib/wlang/scope/object_scope.rb +25 -0
- data/lib/wlang/scope/proxy_scope.rb +18 -0
- data/lib/wlang/scope/root_scope.rb +24 -0
- data/lib/wlang/template.rb +16 -86
- data/lib/wlang/version.rb +9 -8
- data/spec/fixtures/dialect/foobar.rb +31 -0
- data/spec/fixtures/dialect/upcasing.rb +13 -0
- data/spec/fixtures/templates/hello.tpl +1 -0
- data/spec/integration/examples/1-basics.txt +65 -0
- data/spec/integration/examples/2-imperative.txt +51 -0
- data/spec/integration/examples/3-partials.txt +76 -0
- data/spec/integration/examples/4-recursion.txt +16 -0
- data/spec/integration/html/test_ampersand.rb +15 -0
- data/spec/integration/html/test_bang.rb +38 -0
- data/spec/integration/html/test_caret.rb +33 -0
- data/spec/integration/html/test_dollar.rb +16 -0
- data/spec/integration/html/test_greater.rb +23 -0
- data/spec/integration/html/test_modulo.rb +16 -0
- data/spec/integration/html/test_plus.rb +48 -0
- data/spec/integration/html/test_question.rb +33 -0
- data/spec/integration/html/test_sharp.rb +21 -0
- data/spec/integration/html/test_slash.rb +16 -0
- data/spec/integration/html/test_star.rb +37 -0
- data/spec/integration/test_dummy.rb +51 -0
- data/spec/integration/test_examples.rb +29 -0
- data/spec/integration/test_mustang.rb +120 -0
- data/spec/integration/test_readme.rb +56 -0
- data/spec/integration/test_upcasing.rb +22 -0
- data/spec/spec_helper.rb +62 -1
- data/spec/test_wlang.rb +101 -0
- data/spec/unit/compiler/autospacing/test_right_strip.rb +30 -0
- data/spec/unit/compiler/autospacing/test_unindent.rb +30 -0
- data/spec/unit/compiler/test_dialect_enforcer.rb +168 -0
- data/spec/unit/compiler/test_grammar.rb +207 -0
- data/spec/unit/compiler/test_parser.rb +69 -0
- data/spec/unit/compiler/test_proc_call_removal.rb +24 -0
- data/spec/unit/compiler/test_static_merger.rb +29 -0
- data/spec/unit/compiler/test_strconcat_flattener.rb +30 -0
- data/spec/unit/compiler/test_to_ruby_abstraction.rb +59 -0
- data/spec/unit/compiler/test_to_ruby_code.rb +24 -0
- data/spec/unit/dialect/test_compile.rb +52 -0
- data/spec/unit/dialect/test_dispatching.rb +19 -0
- data/spec/unit/dialect/test_evaluate.rb +41 -0
- data/spec/unit/dialect/test_render.rb +33 -0
- data/spec/unit/dialect/test_tags.rb +32 -0
- data/spec/unit/dialect/test_with_scope.rb +18 -0
- data/spec/unit/scope/test_binding_scope.rb +27 -0
- data/spec/unit/scope/test_coerce.rb +22 -0
- data/spec/unit/scope/test_object_scope.rb +38 -0
- data/spec/unit/scope/test_proxy_scope.rb +22 -0
- data/spec/unit/scope/test_root_scope.rb +22 -0
- data/spec/unit/test_assumptions.rb +29 -0
- data/spec/unit/test_scope.rb +57 -0
- data/tasks/debug_mail.rake +42 -45
- data/tasks/gem.rake +22 -17
- data/tasks/spec_test.rake +9 -17
- data/tasks/unit_test.rake +11 -12
- data/tasks/yard.rake +13 -13
- data/wlang.gemspec +36 -32
- data/wlang.noespec +27 -35
- metadata +268 -451
- data/doc/specification/about.rdoc +0 -61
- data/doc/specification/analytics.wtpl +0 -13
- data/doc/specification/dialect.wtpl +0 -14
- data/doc/specification/dialects.wtpl +0 -3
- data/doc/specification/examples.rb +0 -3
- data/doc/specification/glossary.wtpl +0 -14
- data/doc/specification/hosting.rdoc +0 -0
- data/doc/specification/overview.rdoc +0 -116
- data/doc/specification/rulesets.wtpl +0 -87
- data/doc/specification/specification.css +0 -53
- data/doc/specification/specification.html +0 -1690
- data/doc/specification/specification.js +0 -8
- data/doc/specification/specification.wtpl +0 -42
- data/doc/specification/specification.yml +0 -432
- data/doc/specification/symbols.wtpl +0 -16
- data/lib/wlang/dialect_dsl.rb +0 -141
- data/lib/wlang/dialect_loader.rb +0 -74
- data/lib/wlang/dialects/bluecloth_dialect.rb +0 -16
- data/lib/wlang/dialects/coderay_dialect.rb +0 -45
- data/lib/wlang/dialects/hosted_dialect.rb +0 -50
- data/lib/wlang/dialects/plain_text_dialect.rb +0 -69
- data/lib/wlang/dialects/rdoc_dialect.rb +0 -33
- data/lib/wlang/dialects/redcloth_dialect.rb +0 -16
- data/lib/wlang/dialects/ruby_dialect.rb +0 -118
- data/lib/wlang/dialects/sql_dialect.rb +0 -38
- data/lib/wlang/dialects/standard_dialects.rb +0 -181
- data/lib/wlang/dialects/xhtml_dialect.rb +0 -63
- data/lib/wlang/dialects/yaml_dialect.rb +0 -30
- data/lib/wlang/encoder.rb +0 -62
- data/lib/wlang/encoder_set.rb +0 -122
- data/lib/wlang/errors.rb +0 -80
- data/lib/wlang/ext/hash_methodize.rb +0 -13
- data/lib/wlang/ext/string.rb +0 -44
- data/lib/wlang/hash_scope.rb +0 -89
- data/lib/wlang/hosted_language.rb +0 -146
- data/lib/wlang/intelligent_buffer.rb +0 -94
- data/lib/wlang/parser.rb +0 -332
- data/lib/wlang/parser_state.rb +0 -94
- data/lib/wlang/rule.rb +0 -66
- data/lib/wlang/rule_set.rb +0 -106
- data/lib/wlang/rulesets/basic_ruleset.rb +0 -83
- data/lib/wlang/rulesets/buffering_ruleset.rb +0 -115
- data/lib/wlang/rulesets/context_ruleset.rb +0 -111
- data/lib/wlang/rulesets/encoding_ruleset.rb +0 -73
- data/lib/wlang/rulesets/imperative_ruleset.rb +0 -132
- data/lib/wlang/rulesets/ruleset_utils.rb +0 -317
- data/lib/wlang/wlang_command.rb +0 -51
- data/lib/wlang/wlang_command_options.rb +0 -163
- data/spec/basic_object.spec +0 -40
- data/spec/coderay_dialect.spec +0 -8
- data/spec/dialect/apply_post_transform.spec +0 -16
- data/spec/global_extensions.rb +0 -2
- data/spec/hash_scope.spec +0 -76
- data/spec/redcloth_dialect.spec +0 -24
- data/spec/test_all.rb +0 -8
- data/spec/wlang.spec +0 -53
- data/spec/wlang_spec.rb +0 -8
- data/spec/xhtml_dialect.spec +0 -22
- data/tasks/genspec.rake +0 -5
- data/test/blackbox/basic/execution_1.exp +0 -1
- data/test/blackbox/basic/execution_1.tpl +0 -1
- data/test/blackbox/basic/execution_2.exp +0 -1
- data/test/blackbox/basic/execution_2.tpl +0 -1
- data/test/blackbox/basic/execution_3.exp +0 -1
- data/test/blackbox/basic/execution_3.tpl +0 -1
- data/test/blackbox/basic/execution_4.exp +0 -1
- data/test/blackbox/basic/execution_4.tpl +0 -1
- data/test/blackbox/basic/inclusion_1.exp +0 -1
- data/test/blackbox/basic/inclusion_1.tpl +0 -1
- data/test/blackbox/basic/inclusion_2.exp +0 -1
- data/test/blackbox/basic/inclusion_2.tpl +0 -1
- data/test/blackbox/basic/injection_1.exp +0 -1
- data/test/blackbox/basic/injection_1.tpl +0 -1
- data/test/blackbox/basic/injection_2.exp +0 -1
- data/test/blackbox/basic/injection_2.tpl +0 -1
- data/test/blackbox/basic/modulation_1.exp +0 -1
- data/test/blackbox/basic/modulation_1.tpl +0 -1
- data/test/blackbox/basic/modulation_2.exp +0 -1
- data/test/blackbox/basic/modulation_2.tpl +0 -1
- data/test/blackbox/basic/recursive_app_1.exp +0 -1
- data/test/blackbox/basic/recursive_app_1.tpl +0 -1
- data/test/blackbox/basic/recursive_app_2.exp +0 -1
- data/test/blackbox/basic/recursive_app_2.tpl +0 -1
- data/test/blackbox/buffering/data_1.rb +0 -1
- data/test/blackbox/buffering/data_assignment_1.exp +0 -1
- data/test/blackbox/buffering/data_assignment_1.tpl +0 -1
- data/test/blackbox/buffering/data_assignment_2.exp +0 -1
- data/test/blackbox/buffering/data_assignment_2.tpl +0 -1
- data/test/blackbox/buffering/data_assignment_3.exp +0 -1
- data/test/blackbox/buffering/data_assignment_3.tpl +0 -1
- data/test/blackbox/buffering/data_assignment_4.exp +0 -1
- data/test/blackbox/buffering/data_assignment_4.tpl +0 -1
- data/test/blackbox/buffering/input_1.exp +0 -1
- data/test/blackbox/buffering/input_1.tpl +0 -1
- data/test/blackbox/buffering/input_2.exp +0 -1
- data/test/blackbox/buffering/input_2.tpl +0 -1
- data/test/blackbox/buffering/input_3.exp +0 -1
- data/test/blackbox/buffering/input_3.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion.exp +0 -1
- data/test/blackbox/buffering/input_inclusion.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_1.exp +0 -0
- data/test/blackbox/buffering/input_inclusion_1.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_2.exp +0 -1
- data/test/blackbox/buffering/input_inclusion_2.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_3.exp +0 -1
- data/test/blackbox/buffering/input_inclusion_3.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_4.exp +0 -0
- data/test/blackbox/buffering/input_inclusion_4.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_5.exp +0 -1
- data/test/blackbox/buffering/input_inclusion_5.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_6.exp +0 -1
- data/test/blackbox/buffering/input_inclusion_6.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_7.exp +0 -0
- data/test/blackbox/buffering/input_inclusion_7.tpl +0 -1
- data/test/blackbox/buffering/text_1.txt +0 -1
- data/test/blackbox/buffering/wlang.txt +0 -1
- data/test/blackbox/context/assignment_1.exp +0 -1
- data/test/blackbox/context/assignment_1.tpl +0 -1
- data/test/blackbox/context/assignment_2.exp +0 -1
- data/test/blackbox/context/assignment_2.tpl +0 -1
- data/test/blackbox/context/assignment_3.exp +0 -2
- data/test/blackbox/context/assignment_3.tpl +0 -2
- data/test/blackbox/context/assignment_4.exp +0 -1
- data/test/blackbox/context/assignment_4.tpl +0 -1
- data/test/blackbox/context/block_assignment_1.exp +0 -1
- data/test/blackbox/context/block_assignment_1.tpl +0 -1
- data/test/blackbox/context/block_assignment_2.exp +0 -1
- data/test/blackbox/context/block_assignment_2.tpl +0 -1
- data/test/blackbox/context/modulo_assignment_1.exp +0 -1
- data/test/blackbox/context/modulo_assignment_1.tpl +0 -1
- data/test/blackbox/context/modulo_assignment_2.exp +0 -1
- data/test/blackbox/context/modulo_assignment_2.tpl +0 -1
- data/test/blackbox/data_1.rb +0 -1
- data/test/blackbox/postblock/hello.exp +0 -1
- data/test/blackbox/postblock/hello.pre +0 -1
- data/test/blackbox/postblock/hello.tpl +0 -1
- data/test/blackbox/postblock/hello_input_inclusion.exp +0 -1
- data/test/blackbox/postblock/hello_input_inclusion.tpl +0 -1
- data/test/blackbox/postblock/hello_to_authors.exp +0 -1
- data/test/blackbox/postblock/hello_to_authors.tpl +0 -1
- data/test/blackbox/poststring/hello.exp +0 -1
- data/test/blackbox/poststring/hello.tpl +0 -1
- data/test/blackbox/test_all.rb +0 -70
- data/test/standard_dialects/ruby/data.rb +0 -7
- data/test/standard_dialects/ruby/inclusion.exp +0 -6
- data/test/standard_dialects/ruby/inclusion.tpl +0 -6
- data/test/standard_dialects/test_all.rb +0 -29
- data/test/standard_dialects/yaml/assumptions_test.rb +0 -13
- data/test/standard_dialects/yaml/data.rb +0 -3
- data/test/standard_dialects/yaml/inclusion_1.exp +0 -7
- data/test/standard_dialects/yaml/inclusion_1.tpl +0 -2
- data/test/standard_dialects/yaml/inclusion_2.exp +0 -5
- data/test/standard_dialects/yaml/inclusion_2.tpl +0 -3
- data/test/unit/test_all.rb +0 -9
- data/test/unit/wlang/anagram_bugs_test.rb +0 -111
- data/test/unit/wlang/basic_ruleset_test.rb +0 -52
- data/test/unit/wlang/buffering_ruleset_test.rb +0 -102
- data/test/unit/wlang/buffering_template1.wtpl +0 -1
- data/test/unit/wlang/buffering_template2.wtpl +0 -1
- data/test/unit/wlang/buffering_template3.wtpl +0 -1
- data/test/unit/wlang/buffering_template4.wtpl +0 -1
- data/test/unit/wlang/buffering_template5.wtpl +0 -1
- data/test/unit/wlang/context_ruleset_test.rb +0 -32
- data/test/unit/wlang/data.rb +0 -3
- data/test/unit/wlang/encoder_set_test.rb +0 -42
- data/test/unit/wlang/imperative_ruleset_test.rb +0 -107
- data/test/unit/wlang/intelligent_buffer_test.rb +0 -194
- data/test/unit/wlang/othersymbols_test.rb +0 -16
- data/test/unit/wlang/parser_test.rb +0 -88
- data/test/unit/wlang/plain_text_dialect_test.rb +0 -21
- data/test/unit/wlang/ruby_dialect_test.rb +0 -100
- data/test/unit/wlang/ruby_expected.rb +0 -3
- data/test/unit/wlang/ruby_template.wrb +0 -3
- data/test/unit/wlang/ruleset_utils_test.rb +0 -245
- data/test/unit/wlang/specification_examples_test.rb +0 -54
- data/test/unit/wlang/test_utils.rb +0 -25
- data/test/unit/wlang/wlang_test.rb +0 -80
data/CHANGELOG.md
CHANGED
@@ -1,123 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# 2.0.0 / FIX ME
|
2
2
|
|
3
|
-
*
|
3
|
+
* Enhancements
|
4
4
|
|
5
|
-
*
|
6
|
-
block syntaxes. Post-transformation rules related strategies are now:
|
7
|
-
- Parser#instantiate now takes an optional boolean argument to set/unset dialect
|
8
|
-
post transformation (defaults to true, for backward compatibility).
|
9
|
-
- Invoking Template.instantiate always invoke Parser#instantiate(true)
|
10
|
-
- Buffering's <<+{...} always apply post-transformation as well
|
11
|
-
- Otherwise, post-transformation is only applied when the dialect explicitely changes
|
12
|
-
when invoking Parser#parse and Parser#parse_block
|
13
|
-
|
14
|
-
* Other enhancements
|
15
|
-
|
16
|
-
* Added a bluecloth/xhtml dialect and encoder.
|
17
|
-
|
18
|
-
# Version 0.10.1 / 2011-01-17
|
19
|
-
|
20
|
-
* Bug fixes
|
21
|
-
|
22
|
-
* Fixed a bug when using multi-block syntaxes with another delimiter than braces.
|
23
|
-
|
24
|
-
* Other enhancements
|
25
|
-
|
26
|
-
* WLang source code follows the ruby.noe template that comes bundled with Noe
|
27
|
-
|
28
|
-
# Version 0.10.0 / 2011-01-14
|
29
|
-
|
30
|
-
* New features
|
31
|
-
|
32
|
-
* Introduced a wlang/hosted language which parses blocks as actually described in the specification
|
33
|
-
* Introduced a semantics +{...} in wlang/ruby that prints literals.
|
34
|
-
* wlang/ruby now includes the Buffering ruleset
|
35
|
-
* Introduced a wlang/active-text dialect which includes Basic, Imperative, Buffering and Context rulesets.
|
36
|
-
* Introduced a wlang/yaml dialect with special inclusion +{...} operator
|
37
|
-
|
38
|
-
* Broken features and APIs
|
39
|
-
|
40
|
-
* Due to the wlang/ruby <-> wlang/hosted changes and the fact that wlang/ruby now includes the
|
41
|
-
Buffering ruleset, users that generate ruby (a few) may have broken templates and should probably
|
42
|
-
be pessimist and require wlang 0.9.x
|
43
|
-
* For the same reason, users that make complex wlang meta-constructions ala +{+{...}} could observe
|
44
|
-
problems due to the change of +{...} in wlang/ruby. The wlang/hosted dialect is introduced to limit
|
45
|
-
such problems, but not encountering them is not guaranteed.
|
46
|
-
|
47
|
-
* Other enhancements
|
48
|
-
|
49
|
-
* Moved to rspec 2.4.0
|
50
|
-
* Moved from rdoc to yard for generating the documentation
|
51
|
-
* README, CHANGELOG and LICENCE are now in Mardown instead of rdoc
|
52
|
-
|
53
|
-
# Version 0.9.2
|
54
|
-
|
55
|
-
* New features (by order of importance)
|
56
|
-
|
57
|
-
* Implements main transformer on dialects
|
58
|
-
* Makes coderay encoders available without options using a bit of meta programming
|
59
|
-
* System-local absolute paths (i.e. starting with '/') are recognized by buffer rulesets
|
60
|
-
|
61
|
-
# Version 0.9.1
|
62
|
-
|
63
|
-
* Bug fixes
|
64
|
-
|
65
|
-
* #307, about HashScope.has_key? which returned nil instead of false in some situations
|
66
|
-
|
67
|
-
* Broken features and APIs (by order of importance)
|
68
|
-
|
69
|
-
* HostedLanguage::DSL is strictly private and should be reopened. Methods added to this class
|
70
|
-
will never be available in templates. Use HostedLanguage.variable_missing instead.
|
71
|
-
* ::WLang::BasicObject has been removed. HostedLanguage::DSL implements its own strategy, which
|
72
|
-
is spec tested in test/spec/basic_object.spec
|
73
|
-
|
74
|
-
* New features (by order of importance)
|
75
|
-
|
76
|
-
* WLang does not requires the rdoc gem by default
|
77
|
-
* A new encoder redcloth/xhtml allows using Textile markups easily
|
78
|
-
* The wlang/xhtml dialect provides a tag helper for links @{...}{...}
|
79
|
-
* The parser class returns friendly messages when a rule is ill-implemented
|
80
|
-
|
81
|
-
# Version 0.9.0
|
82
|
-
|
83
|
-
* Broken features and APIs (by order of importance)
|
84
|
-
|
85
|
-
* Major broken API in WLang.instantiate and WLang.file_instantiate which do not allow passing
|
86
|
-
buffers anymore
|
87
|
-
* Hash are not methodized by default anymore (major broken feature with 0.8.x versions)
|
88
|
-
* Expressions 'a la' PHP w@w (sections/.../.../id) are not supported anymore
|
89
|
-
* The default hosted language raises a WLang::UndefinedVariableError when a variable cannot be
|
90
|
-
found in the current template scope (0.8.x versions returned nil in this case)
|
91
|
-
* Template.initialize does not take a default context anymore
|
92
|
-
* WLang::Parser.context_xxx do not exist anymore. Use branch(...) instead
|
93
|
-
* WLang::Parser::Context removed, and WLang::HashScope introduced
|
94
|
-
* WLang::Parser instance variables are all made protected
|
95
|
-
|
96
|
-
* New features (by order of importance)
|
97
|
-
|
98
|
-
* WLang::HostingLanguage introduced, with a default one for Ruby. The hosting language
|
99
|
-
is the way to provide a main scope, accessible to all templates at once.
|
100
|
-
* WLang::HostingLanguage is not sensitive to the difference between symbol keys and strings
|
101
|
-
* Buffering and Context rulesets now branch the current parser instead of creating a new one
|
102
|
-
* WLang::Error and subclasses propose a backtrace information
|
103
|
-
* WLang::Parser refactored to encapsulate the whole state in another class (WLang::Parser::State)
|
104
|
-
* WLang facade has been made much more robust as it now checks all its arguments.
|
105
|
-
* WLang::dialect may now be used to ensure dialect instances from both Dialect args and qualified names.
|
106
|
-
* Introduction of WLang.template and WLang.file_template
|
107
|
-
* plain-text dialect proposes new camel-based encoders
|
108
|
-
* wlang/active-string dialect has the imperative rule set included
|
109
|
-
* sql dialect has been added
|
110
|
-
* ruby dialect proposes a method-case encoder
|
111
|
-
|
112
|
-
# Version 0.8.5
|
113
|
-
|
114
|
-
* Enhances error messages a lot
|
115
|
-
* Some bug fixes for ruby 0.8.7
|
116
|
-
|
117
|
-
# Version 0.8.4
|
118
|
-
|
119
|
-
* Migration from svn.chefbe.net to github.com
|
120
|
-
|
121
|
-
# Version 0.8.0
|
122
|
-
|
123
|
-
* First public version
|
5
|
+
* Birthday!
|
data/Gemfile
CHANGED
@@ -1,2 +1,24 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
|
-
|
2
|
+
|
3
|
+
group :runtime do
|
4
|
+
gem "citrus", "~> 2.4.1"
|
5
|
+
gem "temple", "~> 0.4.0"
|
6
|
+
gem "backports", "~> 2.6.1", :platforms => ["ruby_18", "mri_18", "mingw_18", 'jruby']
|
7
|
+
gem "quickl", "~> 0.4.3"
|
8
|
+
gem "awesome_print", "~> 1.0.2"
|
9
|
+
end
|
10
|
+
|
11
|
+
group :profiling do
|
12
|
+
gem "ruby-prof", "~> 0.11.2"
|
13
|
+
gem "mustache", "~> 0.99.4"
|
14
|
+
#gem "viiite", :git => "git://github.com/blambeau/viiite.git"
|
15
|
+
end
|
16
|
+
|
17
|
+
group :development do
|
18
|
+
gem "rake", "~> 0.9.2"
|
19
|
+
gem "bundler", "~> 1.0"
|
20
|
+
gem "rspec", "~> 2.10.0"
|
21
|
+
gem "epath", "~> 0.1.0"
|
22
|
+
gem "yard", "~> 0.8.1"
|
23
|
+
gem "bluecloth", "~> 2.2.0"
|
24
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,37 +1,41 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
wlang (0.10.2)
|
5
|
-
|
6
1
|
GEM
|
7
2
|
remote: http://rubygems.org/
|
8
3
|
specs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
rspec-
|
23
|
-
|
4
|
+
awesome_print (1.0.2)
|
5
|
+
backports (2.6.1)
|
6
|
+
bluecloth (2.2.0)
|
7
|
+
citrus (2.4.1)
|
8
|
+
diff-lcs (1.1.3)
|
9
|
+
epath (0.1.1)
|
10
|
+
mustache (0.99.4)
|
11
|
+
quickl (0.4.3)
|
12
|
+
rake (0.9.2.2)
|
13
|
+
rspec (2.10.0)
|
14
|
+
rspec-core (~> 2.10.0)
|
15
|
+
rspec-expectations (~> 2.10.0)
|
16
|
+
rspec-mocks (~> 2.10.0)
|
17
|
+
rspec-core (2.10.1)
|
18
|
+
rspec-expectations (2.10.0)
|
19
|
+
diff-lcs (~> 1.1.3)
|
20
|
+
rspec-mocks (2.10.1)
|
21
|
+
ruby-prof (0.11.2)
|
22
|
+
temple (0.4.0)
|
23
|
+
yard (0.8.1)
|
24
24
|
|
25
25
|
PLATFORMS
|
26
26
|
ruby
|
27
27
|
|
28
28
|
DEPENDENCIES
|
29
|
-
|
30
|
-
|
29
|
+
awesome_print (~> 1.0.2)
|
30
|
+
backports (~> 2.6.1)
|
31
|
+
bluecloth (~> 2.2.0)
|
31
32
|
bundler (~> 1.0)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
citrus (~> 2.4.1)
|
34
|
+
epath (~> 0.1.0)
|
35
|
+
mustache (~> 0.99.4)
|
36
|
+
quickl (~> 0.4.3)
|
37
|
+
rake (~> 0.9.2)
|
38
|
+
rspec (~> 2.10.0)
|
39
|
+
ruby-prof (~> 0.11.2)
|
40
|
+
temple (~> 0.4.0)
|
41
|
+
yard (~> 0.8.1)
|
data/LICENCE.md
CHANGED
@@ -1,25 +1,22 @@
|
|
1
|
-
# Licence
|
1
|
+
# The MIT Licence
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2012 - Bernard Lambeau, Louis Lambeau
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
copies of the Software, and to permit persons to whom the Software is
|
13
|
-
furnished to do so, subject to the following conditions:
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
14
12
|
|
15
|
-
|
16
|
-
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
|
1
|
+
wlang.gemspec
|
2
|
+
wlang.noespec
|
3
|
+
.gemtest
|
2
4
|
CHANGELOG.md
|
3
|
-
doc/specification/**/*
|
4
|
-
example/**/*
|
5
5
|
Gemfile
|
6
6
|
Gemfile.lock
|
7
|
+
bin/**/*
|
7
8
|
lib/**/*
|
8
9
|
LICENCE.md
|
9
10
|
Manifest.txt
|
@@ -12,5 +13,3 @@ README.md
|
|
12
13
|
spec/**/*
|
13
14
|
tasks/**/*
|
14
15
|
test/**/*
|
15
|
-
wlang.gemspec
|
16
|
-
wlang.noespec
|
data/README.md
CHANGED
@@ -1,174 +1,100 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
##
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
tpl = tpl.wlang(:varname => 'who') # => Hello $(who)!
|
102
|
-
tpl = tpl.wlang({:who => 'wlang'}, dialect, :parentheses) # => Hello wlang!
|
103
|
-
|
104
|
-
## Roadmap
|
105
|
-
|
106
|
-
- For terminology and a quick overview of _wlang_ for generating code, read on.
|
107
|
-
- For the current cheatsheet/specification see the file doc/specification/specification.html
|
108
|
-
- If you want to learn _wlang_ quickly, see the example directory or read examples
|
109
|
-
in the specification file (if you understand all examples in the specification file, then you
|
110
|
-
probably master wlang.
|
111
|
-
- If you want a killer example (but simple) see the way the specification.html file
|
112
|
-
is generated in doc/specification directory
|
113
|
-
- If you want to know which dialects are available (that is, in which target languages
|
114
|
-
you can generate code), see the specification as well or read the file
|
115
|
-
lib/wlang/dialects/standard_dialects.rb in the source distribution.
|
116
|
-
- If you want to create your own wlang dialect, see WLang::Dialect::DSL
|
117
|
-
- If you think that your own dialect is of generic purpose and well-designed, if
|
118
|
-
you have any question or want to contribute join us on {github}[http://github.com/blambeau/wlang].
|
119
|
-
|
120
|
-
## Terminology
|
121
|
-
|
122
|
-
_wlang_ comes with a well-defined terminology for the underlying abstractions. As
|
123
|
-
the documentation uses it, you'll probably be happy to learn about the main abstractions
|
124
|
-
and associated terms.
|
125
|
-
|
126
|
-
_template_ : Source code respecting the wlang grammar, and attached to a given <em>wlang
|
127
|
-
dialect</em>. Asbtraction implemented by WLang::Template.
|
128
|
-
|
129
|
-
_dialect_ : Basically, <em>dialect</em> is used as a synonym for (programming) <em>language</em>.
|
130
|
-
However _wlang_ uses a tree of dialects, allowing specializations: <tt>sql/sybase</tt>
|
131
|
-
for example is the qualified name of a sub-dialect 'sybase' of the 'sql' dialect.
|
132
|
-
Dialects come with associated _encoders_. Abstraction implemented by WLang::Dialect.
|
133
|
-
|
134
|
-
_wlang dialect_ : When we talk about a <em>wlang dialect</em>, we are actually refering to some
|
135
|
-
specialization of the wlang tag-based grammar: <tt>wlang/xhtml</tt> for example
|
136
|
-
is the templating language _wlang_ proposes to generate xhtml pages. An
|
137
|
-
example of source code in that dialect has been shown before.
|
138
|
-
In addition to its encoders a <em>wlang dialect</em> comes with its sets of _tags_
|
139
|
-
and associated _rules_. Abstraction implemented by WLang::Dialect as well as
|
140
|
-
WLang::EncoderSet and WLang::RuleSet.
|
141
|
-
|
142
|
-
_encoder set_ : Reusable set of <em>encoders</em>, attached to a dialect. Abstraction
|
143
|
-
implemented by WLang::EncoderSet.
|
144
|
-
|
145
|
-
_encoder_ : Text transformation (algorithm) applying some encoding conventions of a portion
|
146
|
-
of a the target language generated by a dialect. HTML entities-encoding, SQL's back-quoting
|
147
|
-
are examples of encoders. Encoders are accessible through their qualified name:
|
148
|
-
xhtml/entities-encoding and sql/back-quoting in the examples. Abstraction implemented by
|
149
|
-
WLang::Encoder.
|
150
|
-
|
151
|
-
_ruleset_ : Reusable set of <em>tags</em> associated to <em>rule</em>s. Abstraction
|
152
|
-
implemented by WLang::RuleSet.
|
153
|
-
|
154
|
-
_wlang tag_ : Special tags in the template, starting with wlang symbols and a number of wlang
|
155
|
-
blocks. A tag is associated with a wlang rule. Examples: <tt>${...}</tt> is a
|
156
|
-
tag with only one block, while <tt>?{...}{...}{...}</tt> is another tag but with
|
157
|
-
three blocks.
|
158
|
-
|
159
|
-
_rule_ : Transformation semantics of a given <em>tag</em>. When wlang instantiates a
|
160
|
-
template it simply replaces <em>wlang tags</em> by some <em>replacement value</em>
|
161
|
-
(which is always a string). This value is computed by the rule attached to
|
162
|
-
the tag. Rule definition explicitly describes the number of blocks it expects, in which dialect they
|
163
|
-
are parsed and instantiated and the way the replacement value is computed.
|
164
|
-
Example: <tt>^{wlang/active-string}{...}</tt> (also known as 'encoding')
|
165
|
-
instantiates #1, looking for an encoder qualified name. Instantiates #2 in
|
166
|
-
the current dialect. Encode #2's instantiation using encoder found in (#1)
|
167
|
-
|
168
|
-
_context_ : Some rules allow code to be executed in the <em>hosting language</em> (the
|
169
|
-
definition explicitly announce it by putting <tt>wlang/hosted</tt> in the corresponding
|
170
|
-
block). When doing so, this code is in fact executed in a given context that
|
171
|
-
provides the execution semantics. Abstraction implemented in WLang::Parser::Context.
|
172
|
-
|
173
|
-
_hosting language_ : language (or framework) that executes wlang. In this case, it will be
|
174
|
-
<tt>ruby</tt>.
|
1
|
+
# WLang
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/blambeau/wlang.png?branch=wlang2)](http://travis-ci.org/blambeau/wlang)
|
4
|
+
|
5
|
+
WLang is a powerful code generation and templating engine.
|
6
|
+
|
7
|
+
This is the README of wlang2, a fresh new implementation of the [wlang templating language concept](http://revision-zero.org/wlang), this one implemented on top of [temple](https://github.com/judofyr/temple) and much inspired by the excellent [mustache](http://mustache.github.com/). (For users of wlang 1.0 (formaly 0.10.2), this rewrite cleans most concepts as well as the abstract wlang semantics; it also uses a simple compiler architecture to gain huge perfomance gains in comparison to early wlang days).
|
8
|
+
|
9
|
+
**WLang2 is work in progress**. It does not support rubinius so far, due to an incompatibility with the Citrus parser generator. It also have some issues with spacing; not a big issue for HTML rendering but might prevent certain generation tasks.
|
10
|
+
|
11
|
+
## Links
|
12
|
+
|
13
|
+
* http://github.com/blambeau/wlang
|
14
|
+
* http://blambeau.github.com/wlang
|
15
|
+
* http://rubygems.org/gems/wlang
|
16
|
+
* http://revision-zero.org/wlang
|
17
|
+
|
18
|
+
## A user-defined templating engine
|
19
|
+
|
20
|
+
WLang is a templating engine, written in ruby. In that, it is similar to ERB, Mustache and the like:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
WLang::Html.render 'Hello to ${who}!', who: 'you & the world'
|
24
|
+
# => "Hello you & the world!"
|
25
|
+
```
|
26
|
+
|
27
|
+
To output HTML pages, WLang does not provides you with killer features or extraordinary shortcus. It supports escaping, as shown above, but many other templating engines do. For such HTML tasks, WLang does a pretty good job but many other engines perform faster and have nicer features. See the examples folder that documents WLang::Html.
|
28
|
+
|
29
|
+
WLang is designed to help you for other uses cases, user-defined ones in particular, such as generating code or whatever text generation task for which other engines quickly become inappropriate. WLang helps there because it allows you to create your own _dialect_, that is, you can define your own tags and their behavior. For instance,
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
class Highlighter < WLang::Dialect
|
33
|
+
|
34
|
+
def highlight(buf, fn)
|
35
|
+
var_name = render(fn)
|
36
|
+
var_value = evaluate(var_name)
|
37
|
+
buf << var_value.to_s.upcase
|
38
|
+
end
|
39
|
+
|
40
|
+
tag '$', :highlight
|
41
|
+
end
|
42
|
+
Highlighter.render('Hello ${who}!'), who: 'you & the world'
|
43
|
+
# => "Hello YOU & THE WORLD !"
|
44
|
+
```
|
45
|
+
|
46
|
+
WLang already provides a few useful dialects, such as WLang::Mustang (mimicing mustache) and WLang::Html (a bit more powerful in my opinion). If they don't match your needs, it is up to you to define you own dialect for making your generation task easy. Have a look at the implementation of WLang's ones, it's pretty simple to get started!
|
47
|
+
|
48
|
+
## Abstract semantics
|
49
|
+
|
50
|
+
WLang has a powerful semantics in terms of concatenation of strings and high-order functions (i.e. functions that take other functions as parameters). Let take the following template as an example:
|
51
|
+
|
52
|
+
```
|
53
|
+
Hello ${who} !
|
54
|
+
```
|
55
|
+
|
56
|
+
The functional semantics of this template is as follows:
|
57
|
+
|
58
|
+
```clojure
|
59
|
+
(fn (concat "Hello", ($ (fn "who")), " !"))
|
60
|
+
```
|
61
|
+
|
62
|
+
That is, the compilation of this template yields a function that concatenates the
|
63
|
+
string `"Hello"` with the result of the higher-order function `($ )` (that itself takes another function as a parameter, corresponding to the sub-template in its brackets delimited blocks) and then the string `" !"`. Providing a concrete semantics to those high-order functions yields so called WLang _dialects_, as we've seen before.
|
64
|
+
|
65
|
+
Having a well-defined semantics allows wlang to properly compile your user-defined dialect and its instantiation engine so as to preserve decent performances. The WLang architecture is a typical compiler chain. This means that, provided some additional coding, you could even define your own language/syntax and reuse the compilation mechanism, provided that you preserve the semantics above.
|
66
|
+
|
67
|
+
## Higher-order constructs
|
68
|
+
|
69
|
+
A feature that distinguishes WLang from most templating engines is the fact that higher-level constructions are permitted. In addition to tag functions that accept multiple arguments, thus multiple blocks in the source text, those blocks may be complex templates themselves.
|
70
|
+
|
71
|
+
For instance, the following behavior is perfectly implementable:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
HighLevel.render 'Hello *{ ${collection} }{ ${self} }{ and } !',
|
75
|
+
collection: 'whos', whos: [ "you", "wlang", "world" ]
|
76
|
+
# => "Hello you and wlang and world"
|
77
|
+
```
|
78
|
+
|
79
|
+
An implementation of `HighLevel` might be as follows:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
class HighLevel < WLang::Dialect
|
83
|
+
|
84
|
+
def join(buf, expr, main, between)
|
85
|
+
evaluate(expr).each_with_index do |val,i|
|
86
|
+
buf << render(between, val) unless i==0
|
87
|
+
buf << render(main, val).strip
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def print(buf, fn)
|
92
|
+
buf << evaluate(fn).to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
tag '*', :join
|
96
|
+
tag '$', :print
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
Use at your own risk, though, as it might lead to dialects that are difficult to understand and/or use and present serious injections risks! Otherwise, higher-order constructions provides you with very powerful tools.
|