wlang 0.10.0 → 0.10.1
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/CHANGELOG.md +72 -62
- data/Gemfile +2 -0
- data/Gemfile.lock +37 -0
- data/Manifest.txt +16 -0
- data/README.md +5 -7
- data/Rakefile +23 -0
- data/doc/specification/analytics.wtpl +13 -0
- data/doc/specification/dialects.wtpl +1 -1
- data/doc/specification/specification.html +199 -169
- data/doc/specification/specification.wtpl +1 -0
- data/doc/specification/specification.yml +1 -1
- data/lib/wlang.rb +3 -2
- data/lib/wlang/loader.rb +0 -0
- data/lib/wlang/parser.rb +1 -1
- data/lib/wlang/template.rb +5 -0
- data/{test/spec → spec}/basic_object.spec +1 -1
- data/{test/spec → spec}/coderay_dialect.spec +1 -1
- data/{test/spec → spec}/dialect/apply_post_transform.spec +0 -0
- data/{test/spec → spec}/global_extensions.rb +0 -0
- data/{test/spec → spec}/hash_scope.spec +1 -1
- data/{test/spec → spec}/redcloth_dialect.spec +1 -1
- data/spec/spec_helper.rb +2 -0
- data/{test/spec → spec}/test_all.rb +0 -0
- data/{test/spec → spec}/wlang.spec +1 -1
- data/spec/wlang_spec.rb +8 -0
- data/{test/spec → spec}/xhtml_dialect.spec +1 -2
- data/tasks/debug_mail.rake +77 -0
- data/tasks/debug_mail.txt +13 -0
- data/tasks/gem.rake +68 -0
- data/tasks/genspec.rake +5 -0
- data/tasks/spec_test.rake +79 -0
- data/tasks/unit_test.rake +76 -0
- data/tasks/yard.rake +51 -0
- data/wlang.gemspec +193 -0
- data/wlang.noespec +54 -0
- metadata +478 -80
data/CHANGELOG.md
CHANGED
@@ -1,86 +1,96 @@
|
|
1
|
-
# Version 0.10.
|
1
|
+
# Version 0.10.1 / 2011-01-17
|
2
2
|
|
3
|
-
|
3
|
+
* Bug fixes
|
4
4
|
|
5
|
-
*
|
6
|
-
* Introduced a semantics +{...} in wlang/ruby that prints literals.
|
7
|
-
* wlang/ruby now includes the Buffering ruleset
|
8
|
-
* Introduced a wlang/active-text dialect which includes Basic, Imperative, Buffering and Context rulesets.
|
9
|
-
* Introduced a wlang/yaml dialect with special inclusion +{...} operator
|
5
|
+
* Fixed a bug when using multi-block syntaxes with another delimiter than braces.
|
10
6
|
|
11
|
-
|
7
|
+
* Other enhancements
|
12
8
|
|
13
|
-
*
|
14
|
-
Buffering ruleset, users that generate ruby (a few) may have broken templates and should probably
|
15
|
-
be pessimist and require wlang 0.9.x
|
16
|
-
* For the same reason, users that make complex wlang meta-constructions ala +{+{...}} could observe
|
17
|
-
problems due to the change of +{...} in wlang/ruby. The wlang/hosted dialect is introduced to limit
|
18
|
-
such problems, but not encountering them is not guaranteed.
|
9
|
+
* WLang source code follows the ruby.noe template that comes bundled with Noe
|
19
10
|
|
20
|
-
|
11
|
+
# Version 0.10.0 / 2011-01-16
|
21
12
|
|
22
|
-
*
|
23
|
-
|
24
|
-
*
|
13
|
+
* New features
|
14
|
+
|
15
|
+
* Introduced a wlang/hosted language which parses blocks as actually described in the specification
|
16
|
+
* Introduced a semantics +{...} in wlang/ruby that prints literals.
|
17
|
+
* wlang/ruby now includes the Buffering ruleset
|
18
|
+
* Introduced a wlang/active-text dialect which includes Basic, Imperative, Buffering and Context rulesets.
|
19
|
+
* Introduced a wlang/yaml dialect with special inclusion +{...} operator
|
20
|
+
|
21
|
+
* Broken features and APIs
|
22
|
+
|
23
|
+
* Due to the wlang/ruby <-> wlang/hosted changes and the fact that wlang/ruby now includes the
|
24
|
+
Buffering ruleset, users that generate ruby (a few) may have broken templates and should probably
|
25
|
+
be pessimist and require wlang 0.9.x
|
26
|
+
* For the same reason, users that make complex wlang meta-constructions ala +{+{...}} could observe
|
27
|
+
problems due to the change of +{...} in wlang/ruby. The wlang/hosted dialect is introduced to limit
|
28
|
+
such problems, but not encountering them is not guaranteed.
|
29
|
+
|
30
|
+
* Other enhancements
|
31
|
+
|
32
|
+
* Moved to rspec 2.4.0
|
33
|
+
* Moved from rdoc to yard for generating the documentation
|
34
|
+
* README, CHANGELOG and LICENCE are now in Mardown instead of rdoc
|
25
35
|
|
26
36
|
# Version 0.9.2
|
27
37
|
|
28
|
-
|
38
|
+
* New features (by order of importance)
|
29
39
|
|
30
|
-
* Implements main transformer on dialects
|
31
|
-
* Makes coderay encoders available without options using a bit of meta programming
|
32
|
-
* System-local absolute paths (i.e. starting with '/') are recognized by buffer rulesets
|
40
|
+
* Implements main transformer on dialects
|
41
|
+
* Makes coderay encoders available without options using a bit of meta programming
|
42
|
+
* System-local absolute paths (i.e. starting with '/') are recognized by buffer rulesets
|
33
43
|
|
34
44
|
# Version 0.9.1
|
35
45
|
|
36
|
-
|
46
|
+
* Bug fixes
|
37
47
|
|
38
|
-
* #307, about HashScope.has_key? which returned nil instead of false in some situations
|
48
|
+
* #307, about HashScope.has_key? which returned nil instead of false in some situations
|
39
49
|
|
40
|
-
|
50
|
+
* Broken features and APIs (by order of importance)
|
41
51
|
|
42
|
-
* HostedLanguage::DSL is strictly private and should be reopened. Methods added to this class
|
43
|
-
|
44
|
-
* ::WLang::BasicObject has been removed. HostedLanguage::DSL implements its own strategy, which
|
45
|
-
|
52
|
+
* HostedLanguage::DSL is strictly private and should be reopened. Methods added to this class
|
53
|
+
will never be available in templates. Use HostedLanguage.variable_missing instead.
|
54
|
+
* ::WLang::BasicObject has been removed. HostedLanguage::DSL implements its own strategy, which
|
55
|
+
is spec tested in test/spec/basic_object.spec
|
46
56
|
|
47
|
-
|
57
|
+
* New features (by order of importance)
|
48
58
|
|
49
|
-
* WLang does not requires the rdoc gem by default
|
50
|
-
* A new encoder redcloth/xhtml allows using Textile markups easily
|
51
|
-
* The wlang/xhtml dialect provides a tag helper for links @{...}{...}
|
52
|
-
* The parser class returns friendly messages when a rule is ill-implemented
|
59
|
+
* WLang does not requires the rdoc gem by default
|
60
|
+
* A new encoder redcloth/xhtml allows using Textile markups easily
|
61
|
+
* The wlang/xhtml dialect provides a tag helper for links @{...}{...}
|
62
|
+
* The parser class returns friendly messages when a rule is ill-implemented
|
53
63
|
|
54
64
|
# Version 0.9.0
|
55
65
|
|
56
|
-
|
57
|
-
|
58
|
-
* Major broken API in WLang.instantiate and WLang.file_instantiate which do not allow passing
|
59
|
-
|
60
|
-
* Hash are not methodized by default anymore (major broken feature with 0.8.x versions)
|
61
|
-
* Expressions 'a la' PHP w@w (sections/.../.../id) are not supported anymore
|
62
|
-
* The default hosted language raises a WLang::UndefinedVariableError when a variable cannot be
|
63
|
-
|
64
|
-
* Template.initialize does not take a default context anymore
|
65
|
-
* WLang::Parser.context_xxx do not exist anymore. Use branch(...) instead
|
66
|
-
* WLang::Parser::Context removed, and WLang::HashScope introduced
|
67
|
-
* WLang::Parser instance variables are all made protected
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
* WLang::HostingLanguage introduced, with a default one for Ruby. The hosting language
|
72
|
-
|
73
|
-
* WLang::HostingLanguage is not sensitive to the difference between symbol keys and strings
|
74
|
-
* Buffering and Context rulesets now branch the current parser instead of creating a new one
|
75
|
-
* WLang::Error and subclasses propose a backtrace information
|
76
|
-
* WLang::Parser refactored to encapsulate the whole state in another class (WLang::Parser::State)
|
77
|
-
* WLang facade has been made much more robust as it now checks all its arguments.
|
78
|
-
* WLang::dialect may now be used to ensure dialect instances from both Dialect args and qualified names.
|
79
|
-
* Introduction of WLang.template and WLang.file_template
|
80
|
-
* plain-text dialect proposes new camel-based encoders
|
81
|
-
* wlang/active-string dialect has the imperative rule set included
|
82
|
-
* sql dialect has been added
|
83
|
-
* ruby dialect proposes a method-case encoder
|
66
|
+
* Broken features and APIs (by order of importance)
|
67
|
+
|
68
|
+
* Major broken API in WLang.instantiate and WLang.file_instantiate which do not allow passing
|
69
|
+
buffers anymore
|
70
|
+
* Hash are not methodized by default anymore (major broken feature with 0.8.x versions)
|
71
|
+
* Expressions 'a la' PHP w@w (sections/.../.../id) are not supported anymore
|
72
|
+
* The default hosted language raises a WLang::UndefinedVariableError when a variable cannot be
|
73
|
+
found in the current template scope (0.8.x versions returned nil in this case)
|
74
|
+
* Template.initialize does not take a default context anymore
|
75
|
+
* WLang::Parser.context_xxx do not exist anymore. Use branch(...) instead
|
76
|
+
* WLang::Parser::Context removed, and WLang::HashScope introduced
|
77
|
+
* WLang::Parser instance variables are all made protected
|
78
|
+
|
79
|
+
* New features (by order of importance)
|
80
|
+
|
81
|
+
* WLang::HostingLanguage introduced, with a default one for Ruby. The hosting language
|
82
|
+
is the way to provide a main scope, accessible to all templates at once.
|
83
|
+
* WLang::HostingLanguage is not sensitive to the difference between symbol keys and strings
|
84
|
+
* Buffering and Context rulesets now branch the current parser instead of creating a new one
|
85
|
+
* WLang::Error and subclasses propose a backtrace information
|
86
|
+
* WLang::Parser refactored to encapsulate the whole state in another class (WLang::Parser::State)
|
87
|
+
* WLang facade has been made much more robust as it now checks all its arguments.
|
88
|
+
* WLang::dialect may now be used to ensure dialect instances from both Dialect args and qualified names.
|
89
|
+
* Introduction of WLang.template and WLang.file_template
|
90
|
+
* plain-text dialect proposes new camel-based encoders
|
91
|
+
* wlang/active-string dialect has the imperative rule set included
|
92
|
+
* sql dialect has been added
|
93
|
+
* ruby dialect proposes a method-case encoder
|
84
94
|
|
85
95
|
# Version 0.8.5
|
86
96
|
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wlang (0.10.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
RedCloth (4.2.3)
|
10
|
+
bluecloth (2.0.9)
|
11
|
+
coderay (0.9.7)
|
12
|
+
diff-lcs (1.1.2)
|
13
|
+
rake (0.8.7)
|
14
|
+
rdoc (2.5.11)
|
15
|
+
rspec (2.4.0)
|
16
|
+
rspec-core (~> 2.4.0)
|
17
|
+
rspec-expectations (~> 2.4.0)
|
18
|
+
rspec-mocks (~> 2.4.0)
|
19
|
+
rspec-core (2.4.0)
|
20
|
+
rspec-expectations (2.4.0)
|
21
|
+
diff-lcs (~> 1.1.2)
|
22
|
+
rspec-mocks (2.4.0)
|
23
|
+
yard (0.6.4)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
RedCloth
|
30
|
+
bluecloth (~> 2.0.9)
|
31
|
+
bundler (~> 1.0)
|
32
|
+
coderay
|
33
|
+
rake (~> 0.8.7)
|
34
|
+
rdoc
|
35
|
+
rspec (~> 2.4.0)
|
36
|
+
wlang!
|
37
|
+
yard (~> 0.6.4)
|
data/Manifest.txt
ADDED
data/README.md
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
# What is _wlang_ ?
|
2
2
|
|
3
|
-
|
4
|
-
(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
proposes standard instantiations of this engine for common tasks such as creating SQL queries,
|
9
|
-
instantiating web pages, etc.
|
3
|
+
WLang is a general-purpose *code generation*/*templating engine*. It's main aim is to help you generating
|
4
|
+
web pages, sql queries, ruby code (that is, generating code in general) without having to worry too much
|
5
|
+
about html entities encoding, sql back quoting, string escaping and the like. WLang proposes a generic
|
6
|
+
engine that you can extend to fit your needs. It also proposes standard instantiations of this engine
|
7
|
+
for common tasks such as creating SQL queries, instantiating web pages, and so on.
|
10
8
|
|
11
9
|
Basic concepts and usage is illustrated below. Also have a look at the [detailed specification](http://blambeau.github.com/wlang).
|
12
10
|
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
gem "bundler", "~> 1.0"
|
3
|
+
require "bundler/setup"
|
4
|
+
rescue LoadError => ex
|
5
|
+
puts ex.message
|
6
|
+
abort "Bundler failed to load, (did you run 'gem install bundler' ?)"
|
7
|
+
end
|
8
|
+
|
9
|
+
# Dynamically load the gem spec
|
10
|
+
$gemspec_file = File.expand_path('../wlang.gemspec', __FILE__)
|
11
|
+
$gemspec = Kernel.eval(File.read($gemspec_file))
|
12
|
+
|
13
|
+
# We run tests by default
|
14
|
+
task :default => :test
|
15
|
+
|
16
|
+
#
|
17
|
+
# Install all tasks found in tasks folder
|
18
|
+
#
|
19
|
+
# See .rake files there for complete documentation.
|
20
|
+
#
|
21
|
+
Dir["tasks/*.rake"].each do |taskfile|
|
22
|
+
instance_eval File.read(taskfile), taskfile
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
|
3
|
+
var _gaq = _gaq || [];
|
4
|
+
_gaq.push(['_setAccount', 'UA-16520635-3']);
|
5
|
+
_gaq.push(['_trackPageview']);
|
6
|
+
|
7
|
+
(function() {
|
8
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
9
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
10
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
11
|
+
})();
|
12
|
+
|
13
|
+
</script>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
4
|
<head>
|
5
5
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
-
<title>WLang (version 0.10.
|
6
|
+
<title>WLang (version 0.10.1)</title>
|
7
7
|
<style type="text/css">
|
8
8
|
body {
|
9
9
|
font-family: arial, verdana, sans-serif;
|
@@ -72,7 +72,7 @@ function show(who) {
|
|
72
72
|
//--></script>
|
73
73
|
</head>
|
74
74
|
<body onload="show('about')">
|
75
|
-
<h1 id="title">WLang (version 0.10.
|
75
|
+
<h1 id="title">WLang (version 0.10.1)</h1>
|
76
76
|
<ul id="tabs">
|
77
77
|
|
78
78
|
<li id="symbolsfocus" onclick="show('symbols')">Tag symbols</li>
|
@@ -101,38 +101,44 @@ function show(who) {
|
|
101
101
|
|
102
102
|
<p>
|
103
103
|
WLang is a a reusable and extensible <em>code generator</em>, also known as
|
104
|
-
a
|
104
|
+
a <em>templating engine</em>. Motivation for it can be found at <a
|
105
105
|
href="http://www.revision-zero.org/wlang">www.revision-zero.org/wlang</a>.
|
106
106
|
The current file is the reference of the tool.
|
107
107
|
</p>
|
108
108
|
<h3>Topics</h3>
|
109
109
|
<dl>
|
110
|
-
<dt>Short overview</dt><dd>
|
110
|
+
<dt>Short overview</dt><dd><p>
|
111
|
+
Probably the first section to read! Basic usage of <em>wlang</em> is
|
111
112
|
explained here and pointers are given to continue your learning.
|
112
|
-
|
113
|
+
</p>
|
113
114
|
</dd>
|
114
|
-
<dt>Rulesets</dt><dd>
|
115
|
-
|
115
|
+
<dt>Rulesets</dt><dd><p>
|
116
|
+
Standard rulesets are specified. As most of them are included in standard
|
117
|
+
dialects, looking at standard rulesets is the quickest way to learn all of
|
116
118
|
them at once.
|
117
|
-
|
119
|
+
</p>
|
118
120
|
</dd>
|
119
|
-
<dt>Dialects</dt><dd>
|
120
|
-
|
121
|
-
|
121
|
+
<dt>Dialects</dt><dd><p>
|
122
|
+
Standard dialects are described. This page also provides useful cheatsheets
|
123
|
+
of available tags in standard dialects.
|
124
|
+
</p>
|
122
125
|
</dd>
|
123
|
-
<dt>Hosting language</dt><dd>
|
126
|
+
<dt>Hosting language</dt><dd><p>
|
127
|
+
Somewhat more tricky but powerful. The notion of hosting language is
|
124
128
|
explained more deeply. Implementing you own hosting language abstraction
|
125
129
|
(advanced topic) sometimes leads to cleaner and cross-implementation
|
126
130
|
templates.
|
127
|
-
|
131
|
+
</p>
|
128
132
|
</dd>
|
129
|
-
<dt>Glossary</dt><dd><
|
133
|
+
<dt>Glossary</dt><dd><p>
|
134
|
+
<em>wlang</em> comes with a terminology, knowing it will make your reading
|
130
135
|
easier.
|
131
|
-
|
136
|
+
</p>
|
132
137
|
</dd>
|
133
|
-
<dt>Symbols</dt><dd>
|
138
|
+
<dt>Symbols</dt><dd><p>
|
139
|
+
If you plan to create your own tags, it can be useful to know what is
|
134
140
|
allowed and what is not. This pages covers this topic.
|
135
|
-
|
141
|
+
</p>
|
136
142
|
</dd>
|
137
143
|
</dl>
|
138
144
|
<h3>About this document</h3>
|
@@ -150,9 +156,9 @@ following command:
|
|
150
156
|
The file ‘specification.wtpl’ is almost empty and other files
|
151
157
|
next to it are all kept simple and written in the most appropriate format
|
152
158
|
for the task at hand (YAML for structured parts, RDoc for text sections,
|
153
|
-
sometimes YAML embedding short sentences writted in RDoc style, etc.).
|
159
|
+
sometimes YAML embedding short sentences writted in RDoc style, etc.). One
|
154
160
|
way to learn <em>wlang</em> quickly is to download the source distribution
|
155
|
-
and to look how this is made possible ;-)
|
161
|
+
and to look how this is made possible ;-)
|
156
162
|
</p>
|
157
163
|
<p>
|
158
164
|
This reference document is under a <a
|
@@ -167,30 +173,32 @@ Enjoy <em>wlang</em> !
|
|
167
173
|
</p>
|
168
174
|
<h3>Distribution</h3>
|
169
175
|
<ul>
|
170
|
-
<li>
|
176
|
+
<li><p>
|
177
|
+
The reference implementation of <em>wlang</em>, implemented in Ruby, is
|
171
178
|
freely available as a ‘wlang’ gem (under MIT licence). <br/>
|
172
|
-
Use <tt>'gem install wlang'</tt> to install it. For repository and
|
173
|
-
tracker visit us on <a href="http://github.com/blambeau/wlang">github</a>
|
174
|
-
|
179
|
+
Use <tt>'gem install wlang'</tt> to install it. For repository and bug
|
180
|
+
tracker visit us on <a href="http://github.com/blambeau/wlang">github</a>
|
181
|
+
</p>
|
175
182
|
</li>
|
176
|
-
<li>
|
183
|
+
<li><p>
|
184
|
+
We don’t have another implementation up to now. If you plan to start
|
177
185
|
one in another language, let us know!
|
178
|
-
|
186
|
+
</p>
|
179
187
|
</li>
|
180
188
|
</ul>
|
181
189
|
<h3>Authors</h3>
|
182
190
|
<p>
|
183
191
|
<em>wlang</em> has been initially designed by Bernard and Louis Lambeau
|
184
|
-
during the implementation of w@w, yet another
|
192
|
+
during the implementation of w@w, yet another web framework (proof of
|
185
193
|
concept). They are also maintainers of the reference implementation.
|
186
194
|
</p>
|
187
195
|
<h3>Credits</h3>
|
188
196
|
<p>
|
189
197
|
This work is supported by the <a
|
190
198
|
href="http://www.uclouvain.be/en-ingi.html">department of computer
|
191
|
-
science</a> of the
|
199
|
+
science</a> of the <a
|
192
200
|
href="http://www.uclouvain.be/en-index.html">University of Louvain</a>
|
193
|
-
(EPL/INGI, Universite Catholique de Louvain,
|
201
|
+
(EPL/INGI, Universite Catholique de Louvain, UCL, Louvain-la-Neuve,
|
194
202
|
Belgium).
|
195
203
|
</p>
|
196
204
|
<p>
|
@@ -212,15 +220,15 @@ Wallonia (ReQuest project, RW Conv. 315592 and GISELE project, RW Conv.
|
|
212
220
|
<h3>What is <em>wlang</em> designed for?</h3>
|
213
221
|
<p>
|
214
222
|
<em>wlang</em> helps you <b>generating code</b>, in a broad sense. It was
|
215
|
-
originally the templating engine of
|
216
|
-
While more powerful than the original version, the <b>templating
|
217
|
-
ability of <em>wlang</em> has been kept unchanged. For this
|
218
|
-
generating html code with <em>wlang</em> is probably a bit more
|
219
|
-
generating ruby, java or sql code, to take some examples of
|
220
|
-
<em>wlang</em> can do. It is the author opinion that <em>wlang</em>
|
221
|
-
also become mature quiclky for these tasks because of its foundations:
|
223
|
+
originally the templating engine of w@w, a proof-of-concept web framework.
|
224
|
+
While more powerful than the original version, the <b>templating
|
225
|
+
engine</b> ability of <em>wlang</em> has been kept unchanged. For this
|
226
|
+
reason, generating html code with <em>wlang</em> is probably a bit more
|
227
|
+
mature than generating ruby, java or sql code, to take some examples of
|
228
|
+
what <em>wlang</em> can do. It is the author opinion that <em>wlang</em>
|
229
|
+
will also become mature quiclky for these tasks because of its foundations:
|
222
230
|
<b>its engine is generic</b> (in a sense, <em>wlang</em> does not really
|
223
|
-
care about
|
231
|
+
care about what it generates) but is <b>fully and easily configurable</b>.
|
224
232
|
Generation of html files is mature because <em>wlang</em> has been used a
|
225
233
|
lot for such a job; thus its authors have acquired experience of what is
|
226
234
|
useful when generating simple as well as complex html files. This
|
@@ -232,31 +240,31 @@ contains information for you!)
|
|
232
240
|
</p>
|
233
241
|
<p>
|
234
242
|
Consider this file for example, which is completely self-contained. It
|
235
|
-
consists of several parts, some
|
236
|
-
example - while others are not. It also embeds a complete CSS
|
243
|
+
consists of several parts, some of them being structured - the tables for
|
244
|
+
example - while others are not. It also embeds a complete CSS stylesheet
|
237
245
|
and some javascript functions. We have not written this file manually, nor
|
238
|
-
do we maintain it
|
239
|
-
generated by <em>wlang</em>
|
246
|
+
do we maintain it this way. In fact, this reference document is entirely
|
247
|
+
generated by <em>wlang</em> itself from separated parts written mainly in
|
240
248
|
yaml and rdoc files. Also, the cheatsheets given later contains a lot of
|
241
|
-
examples. To
|
242
|
-
<em>wlang</em> to compute them during generation (technically,
|
249
|
+
examples. To ensure that all of them are correct, we simply ask
|
250
|
+
<em>wlang</em> to compute them during generation (technically, we say that
|
243
251
|
<b><em>wlang</em> naturally allows metaprogramming</b>). Lastly, if
|
244
|
-
<em>wlang</em> can be used inside a web
|
245
|
-
standalone (commandline) tool for generating single files like this
|
246
|
-
multiple files, even if all of them are of different nature.
|
252
|
+
<em>wlang</em> can be used inside a web framework, it can also be used as
|
253
|
+
a standalone (commandline) tool for generating single files like this one
|
254
|
+
or multiple files, even if all of them are of different nature.
|
247
255
|
</p>
|
248
256
|
<p>
|
249
257
|
<b>Maybe you are looking for a code generator for another language than
|
250
|
-
html</b> (which one does not really care,
|
258
|
+
html</b> (which one does not really care, unless really specific; we call
|
251
259
|
it the <em>target language</em>)? Don’t be affraid by our previous
|
252
260
|
words about <em>wlang</em>’s maturity: even in such a case,
|
253
|
-
<em>wlang</em> is your friend.
|
254
|
-
about dialects), which will provide basic utilities for starting and try
|
255
|
-
identify common patterns when you use them. Then simply create special
|
256
|
-
shortcuts that are more friendly to
|
261
|
+
<em>wlang</em> is your friend. Start with an existing dialect (see later
|
262
|
+
about dialects), which will provide basic utilities for starting and try
|
263
|
+
to identify common patterns when you use them. Then simply create special
|
264
|
+
shortcuts that are more friendly to use than combining several existing
|
257
265
|
utils … you are on the way of creating your own mature and reusable
|
258
|
-
dialect
|
259
|
-
it …
|
266
|
+
dialect for that target language. In this case, don’t forget to
|
267
|
+
share it …
|
260
268
|
</p>
|
261
269
|
<h3>Template and instantiation</h3>
|
262
270
|
<p>
|
@@ -279,7 +287,7 @@ value</em>. Consider the following example:
|
|
279
287
|
</pre>
|
280
288
|
<p>
|
281
289
|
Assume that we have some instantitation data through the following hash (or
|
282
|
-
something similar, like a YAML file):
|
290
|
+
something similar, like a YAML file):
|
283
291
|
</p>
|
284
292
|
<pre>
|
285
293
|
{"title" => "Short overview of wlang", "authors" => ["blambeau", "llambeau", "ancailliau"]}
|
@@ -289,7 +297,7 @@ When instantiated this template will produce exactly the same html file
|
|
289
297
|
except for special tags <tt>${title}</tt> and <tt>*{whos as who}{${who}}{,
|
290
298
|
}</tt> that will be replaced by <tt>'Short overview of wlang'</tt> and
|
291
299
|
<tt>'blambeau, llambeau, ancailliau'</tt>, respectively. A lot of tags is
|
292
|
-
available, each of them being
|
300
|
+
available, each of them being designed for a specific task: inserting the
|
293
301
|
value of a variable, iterating over collections, including another file,
|
294
302
|
dynamically loading instantiation data, etc. All of these things are
|
295
303
|
commonly proposed by templating engines and <em>wlang</em> is one of them
|
@@ -297,22 +305,22 @@ commonly proposed by templating engines and <em>wlang</em> is one of them
|
|
297
305
|
</p>
|
298
306
|
<p>
|
299
307
|
Indeed (and maybe surprisingly) <em>wlang</em> can also behave really
|
300
|
-
differently on the same template:
|
301
|
-
<tt>*{...}</tt> or the converse, or not replacing anything, or replacing
|
308
|
+
differently on the same template: replacing <tt>${title}</tt> but not
|
309
|
+
<tt>*{...}</tt> or the converse, or not replacing anything, or replacing
|
302
310
|
both tags but not <tt>${who}</tt>, etc. All of this is possible in
|
303
|
-
<em>wlang</em>. The magic relies under the notion
|
311
|
+
<em>wlang</em>. The magic relies under the notion of <em>dialect</em>,
|
304
312
|
which you need to understand.
|
305
313
|
</p>
|
306
314
|
<h3>Dialects and Rulesets</h3>
|
307
315
|
<p>
|
308
316
|
The notion of dialect drives the recognition of tags as well as their
|
309
|
-
replacement during instantiation.
|
317
|
+
replacement during instantiation. Dialects are what makes <em>wlang</em>
|
310
318
|
really powerful: if instantiated as being written in the
|
311
|
-
<tt>wlang/xhtml</tt>
|
312
|
-
mentionned previously. In contrast, if written in
|
319
|
+
<tt>wlang/xhtml</tt> dialect, the template above will give the result
|
320
|
+
mentionned previously. In contrast, if written in <tt>wlang/dummy</tt> the
|
313
321
|
template will be reproduced whitout any change (no tag replacement at all).
|
314
322
|
This behavior is not hardcoded; it results from the definition of wlang
|
315
|
-
(standard) dialects: <tt>wlang/xhtml</tt>
|
323
|
+
(standard) dialects: <tt>wlang/xhtml</tt> define special meanings for
|
316
324
|
<tt>${...}</tt> and <tt>*{...}{...}{...}</tt> while <tt>wlang/dummy</tt>
|
317
325
|
does not.
|
318
326
|
</p>
|
@@ -320,30 +328,33 @@ does not.
|
|
320
328
|
The replacement of a given <em>tag</em> during instantiation is computed by
|
321
329
|
what we call the <em>rule</em> attached to the tag (keeping rules and tags
|
322
330
|
as different concepts leads to another feature of <em>wlang</em>: you can
|
323
|
-
reuse rule
|
331
|
+
reuse rule implementations and attach them to other tags than those
|
324
332
|
proposed). A dialect comes with a set of (tag, rule) pairs that determine
|
325
333
|
its replacement behavior. Such a set is called a <em>ruleset</em>; for
|
326
|
-
easier reuse, standard
|
327
|
-
packaging of standard rulesets (and maybe implements specific
|
334
|
+
easier reuse, standard rulesets are already implemented. A dialect is a
|
335
|
+
packaging of standard rulesets (and maybe implements specific tag/rule
|
328
336
|
pairs) designed for generating code in a given target language.
|
329
337
|
</p>
|
338
|
+
<pre>
|
339
|
+
|
340
|
+
</pre>
|
330
341
|
<p>
|
331
342
|
A complete <em>wlang</em> implementation already provides standard dialects
|
332
|
-
for common tasks: creating html pages,
|
333
|
-
code in Ruby or in another language, etc. Each dialect comes with special
|
343
|
+
for common tasks: creating html pages, building SQL queries, generating
|
344
|
+
code in Ruby or in another language, etc. Each dialect comes with special
|
334
345
|
tags that are useful for the task at hand (a tag for back-quoting values is
|
335
|
-
useful for creating SQL queries but does not really makes sense
|
346
|
+
useful for creating SQL queries but does not really makes sense for
|
336
347
|
generating an html page where, in contrast, a tag for encoding entities is
|
337
|
-
probably welcome). Such an
|
338
|
-
standard dialects and to create your own dialect by implementing
|
348
|
+
probably welcome). Such an implementation also allows you to extend
|
349
|
+
standard dialects and to create your own dialect by implementing specific
|
339
350
|
tags and rules or by reusing existing ones. Lastlty, the dialect in used
|
340
|
-
during instantiation can be changed
|
351
|
+
during instantiation can be changed dynamically (<em>explicitly</em>, by
|
341
352
|
using the <tt>%{dialect/qualified/name}{...}</tt> standard tag and
|
342
353
|
<em>implicitly</em>, when rules parse their blocks).
|
343
354
|
</p>
|
344
355
|
<p>
|
345
356
|
To learn more about standard dialects and reusable rules, read the
|
346
|
-
‘Dialects’ and ‘Rulesets’ pages of this
|
357
|
+
‘Dialects’ and ‘Rulesets’ pages of this
|
347
358
|
documentation.
|
348
359
|
</p>
|
349
360
|
<h3>Grammar</h3>
|
@@ -354,36 +365,41 @@ instantiation. It is simple, but comes with some constraints that are
|
|
354
365
|
explained below:
|
355
366
|
</p>
|
356
367
|
<ul>
|
357
|
-
<li>
|
368
|
+
<li><p>
|
369
|
+
block delimiters are ’{’ and ’}’ by default;
|
358
370
|
<em>wlang</em> can be configured to use ’(’ and ’)’
|
359
|
-
or ’[’ and ’]’ instead.
|
371
|
+
or ’[’ and ’]’ instead. However, block
|
360
372
|
<b>delimiters are template-specific</b>: only one kind of delimiters can be
|
361
373
|
used inside the same template.
|
362
|
-
|
374
|
+
</p>
|
363
375
|
</li>
|
364
|
-
<li>
|
365
|
-
|
376
|
+
<li><p>
|
377
|
+
block delimiters <b>must always be paired</b>, even when not used for
|
378
|
+
delimiting blocks. If an opening or closing delimiter is not paired, it
|
366
379
|
must be escaped with a backslash, which will not be reproduced. If you want
|
367
380
|
a backslash to appear before a block delimiter in the instantiation result,
|
368
381
|
use a double backslash.
|
369
|
-
|
382
|
+
</p>
|
370
383
|
</li>
|
371
|
-
<li>
|
384
|
+
<li><p>
|
385
|
+
if a given tag has a special meaning in the current dialect and you
|
372
386
|
don’t want it to be replaced by <em>wlang</em> you can escape it with
|
373
387
|
a backslash as well (the backslash will not be reproduced).
|
374
|
-
|
388
|
+
</p>
|
375
389
|
</li>
|
376
|
-
<li>
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
390
|
+
<li><p>
|
391
|
+
some tags (precisely: some rules associated with tags) require multiple
|
392
|
+
blocks (like <tt>*{...}{...}{...}</tt> in <tt>wlang/xhtml</tt> for
|
393
|
+
example, with the third block bein optional). In such a case no character
|
394
|
+
is allowed between the end of a block ’}’ and the start of the
|
395
|
+
next one ’{’, not even spaces or a carriage return. In other
|
396
|
+
words, multiple blocks (that must be interpreted as such) must touch each
|
397
|
+
others using ’}{’ precisely, as ilustrated below. If a
|
398
|
+
non-optional block is missing a parse error is raised by the <em>wlang</em>
|
384
399
|
implementation.
|
385
|
-
|
400
|
+
</p>
|
386
401
|
<pre>
|
402
|
+
|
387
403
|
*{authors as who}{${who}}{, } -> blambeau, llambeau, ancailliau
|
388
404
|
*{authors as who}{${who}} {, } -> blambeaullambeauancailliau {, }
|
389
405
|
*{authors as who} {${who}}{, } -> parse error 1:18, missing block 2 in *{...}{...}
|
@@ -394,10 +410,10 @@ implementation.
|
|
394
410
|
In addition to these constraints, dialects and the hosting language may
|
395
411
|
impose restrictions on what can be put inside specific blocks of tags/rules
|
396
412
|
(for example, ‘authors as who’ is valid as first tag of
|
397
|
-
<tt>*{...}{...}</tt> but not every string is, of course).
|
398
|
-
are not specific to the wlang grammar <em>per se</em> and are
|
399
|
-
the ‘Rulesets’, ‘Dialects’ and
|
400
|
-
language’ pages of this document.
|
413
|
+
<tt>*{...}{...}</tt> but not every string is, of course). These
|
414
|
+
constraints are not specific to the wlang grammar <em>per se</em> and are
|
415
|
+
explained in the ‘Rulesets’, ‘Dialects’ and
|
416
|
+
‘Hosting language’ pages of this document.
|
401
417
|
</p>
|
402
418
|
|
403
419
|
|
@@ -422,45 +438,46 @@ them are also included by standard dialects.
|
|
422
438
|
<h3>How to read this cheatsheet?</h3>
|
423
439
|
<p>
|
424
440
|
First of all, focus on the examples; they are written to let you learn
|
425
|
-
<em>wlang</em> quickly and
|
441
|
+
<em>wlang</em> quickly and deeply. Some of them are a bit difficult to
|
426
442
|
understand but they are representative of <em>wlang</em> powerfulness
|
427
443
|
(don’t be affraid: in practice, some constructions are never used).
|
428
444
|
Don’t forget that the <tt>wlang/dummy</tt> dialect does not recognize
|
429
|
-
any tag. We also assume instantiation
|
445
|
+
any tag. We also assume instantiation data to be the following hash:
|
430
446
|
</p>
|
431
447
|
<pre>
|
432
|
-
{"name" => "O'Neil",
|
448
|
+
{"name" => "O'Neil",
|
433
449
|
"author" => "blambeau"
|
434
450
|
"authors" => ["blambeau", "llambeau", "ancailliau"]}
|
435
451
|
</pre>
|
436
452
|
<p>
|
437
453
|
Moreover, the dialect column in the examples is important; <em>wlang</em>
|
438
|
-
behaves differently
|
454
|
+
behaves differently in different dialects. When the dialect does not care,
|
439
455
|
we use <tt>wlang/*</tt> which means ‘in any dialect that includes
|
440
456
|
this ruleset’.
|
441
457
|
</p>
|
442
458
|
<p>
|
443
459
|
Next, certain rule definitions are given as shortcuts for longer
|
444
460
|
expressions, involving other tags. This is somewhat representative of
|
445
|
-
<em>wlang</em> usage, even if these rules are not actually implemented
|
446
|
-
way (mainly for efficiency concerns). Once again, understanding
|
447
|
-
will help you
|
448
|
-
shortcuts), we use #1, #2, and #3 to refer to
|
449
|
-
Those identifiers are not real <em>wlang</em> constructs, but are
|
450
|
-
here for
|
451
|
-
they are part of the meta-language, not the language <em>per
|
461
|
+
<em>wlang</em> usage, even if these rules are not actually implemented
|
462
|
+
this way (mainly for efficiency concerns). Once again, understanding
|
463
|
+
shortcuts will help you mastering wlang! In definitions (textual as well
|
464
|
+
as shortcuts), we use #1, #2, and #3 to refer to the content of the
|
465
|
+
blocks. Those identifiers are not real <em>wlang</em> constructs, but are
|
466
|
+
only used here for easier explanations (for those who know this kind of
|
467
|
+
vocabulary: they are part of the meta-language, not the language <em>per
|
468
|
+
se</em>).
|
452
469
|
</p>
|
453
470
|
<p>
|
454
471
|
Lastly, dialect names that appear in rule signatures are to be interpreted
|
455
|
-
as an implicit dialect
|
456
|
-
one) is not instantiated in the current dialect
|
457
|
-
the signature. In contrast, when we use ’…’
|
458
|
-
the
|
459
|
-
Implicit dialect modulation is in fact natural: if a block
|
460
|
-
for example, the easiest way is to give it exactly:
|
472
|
+
as an implicit dialect modulation: the corresponding block (often the
|
473
|
+
first one) is not instantiated in the current dialect but in the one
|
474
|
+
specified by the signature. In contrast, when we use ’…’
|
475
|
+
it means that the corresponding block is simply instantiated in the
|
476
|
+
current dialect. Implicit dialect modulation is in fact natural: if a block
|
477
|
+
expects an uri for example, the easiest way is to give it exactly:
|
461
478
|
<tt><<{a/file/to/include.txt}</tt>. But you can even compute it using
|
462
479
|
<em>wlang</em>, as illustrated by the example below. In complex situations
|
463
|
-
you will probably be happy to use a dialect that helps you
|
480
|
+
you will probably be happy to use a dialect that helps you doing so (think
|
464
481
|
at all blocks that expect an expression in the hosting language, for
|
465
482
|
example)!
|
466
483
|
</p>
|
@@ -474,9 +491,9 @@ example)!
|
|
474
491
|
<h3 id="Basic">Basic</h3>
|
475
492
|
<p>
|
476
493
|
The Basic ruleset is commonly installed on any dialect and provides access
|
477
|
-
to <em>wlang</em>
|
494
|
+
to <em>wlang</em> foundations inside your template: requesting the hosting
|
478
495
|
language to execute some expression, changing the current dialect and
|
479
|
-
encoding text.
|
496
|
+
encoding text.
|
480
497
|
</p>
|
481
498
|
|
482
499
|
<table class="ruleset">
|
@@ -490,7 +507,7 @@ encoding text.
|
|
490
507
|
<td class="signature"><tt>!{wlang/hosted}</tt></td>
|
491
508
|
<td class="name">execution</td>
|
492
509
|
<td class="definition">Instantiates #1, looking for an expression of the hosting language.
|
493
|
-
Evaluates it,
|
510
|
+
Evaluates it, looking for any object. Converts it to a string (using to_s
|
494
511
|
for example if Ruby is the hosting language) and returns the result as
|
495
512
|
replacement value.</td>
|
496
513
|
</tr>
|
@@ -498,15 +515,15 @@ replacement value.</td>
|
|
498
515
|
<tr>
|
499
516
|
<td class="signature"><tt>%{wlang/active-string}{...}</tt></td>
|
500
517
|
<td class="name">modulation</td>
|
501
|
-
<td class="definition">Instantiates #1, looking for a dialect qualified name. Instantiates #2
|
502
|
-
according to the rules defined by that dialect and returns the #2’s
|
518
|
+
<td class="definition">Instantiates #1, looking for a dialect qualified name. Instantiates #2
|
519
|
+
according to the rules defined by that dialect and returns the #2’s
|
503
520
|
instantiation as replacement value.</td>
|
504
521
|
</tr>
|
505
522
|
|
506
523
|
<tr>
|
507
524
|
<td class="signature"><tt>^{wlang/active-string}{...}</tt></td>
|
508
525
|
<td class="name">encoding</td>
|
509
|
-
<td class="definition">Instantiates #1, looking for an encoder qualified name. Instantiates #2 in
|
526
|
+
<td class="definition">Instantiates #1, looking for an encoder qualified name. Instantiates #2 in
|
510
527
|
the current dialect. Encode #2’s instantiation using encoder found in
|
511
528
|
(#1) and returns encoding as replacement value.</td>
|
512
529
|
</tr>
|
@@ -514,11 +531,11 @@ the current dialect. Encode #2’s instantiation using encoder found in
|
|
514
531
|
<tr>
|
515
532
|
<td class="signature"><tt>%!{wlang/active-string <using>? <with>?}{...}</tt></td>
|
516
533
|
<td class="name">recursive-application</td>
|
517
|
-
<td class="definition">Instantiates #1, looking for a dialect qualified name. Instantiates #2
|
534
|
+
<td class="definition">Instantiates #1, looking for a dialect qualified name. Instantiates #2 in
|
518
535
|
the current dialect. Instantiates #2’s instantiation in the dialect
|
519
536
|
found in #1, using context installed by ‘using …’ and
|
520
|
-
‘with …’. Returns this
|
521
|
-
(this really advanced rule allows
|
537
|
+
‘with …’. Returns this instantiation as replacement
|
538
|
+
value (this really advanced rule allows metaprogramming).</td>
|
522
539
|
</tr>
|
523
540
|
|
524
541
|
<tr>
|
@@ -637,10 +654,10 @@ found in #1, using context installed by ‘using …’ and
|
|
637
654
|
<p>
|
638
655
|
Almost all languages require escaping/encoding in specific situations:
|
639
656
|
quoted string literals always come with an escaping mechanism
|
640
|
-
(unfortunately different from one language to another),
|
657
|
+
(unfortunately different from one language to another), html requires
|
641
658
|
entities-encoding, etc. The Encoding ruleset proposes shortcut tags for
|
642
|
-
encoding.
|
643
|
-
don’t depend on the effective
|
659
|
+
encoding. Note that these shortcuts are written in such a way that they
|
660
|
+
don’t depend on the effective dialect. <em>wlang</em> hides language
|
644
661
|
and vendors differences!
|
645
662
|
</p>
|
646
663
|
|
@@ -825,7 +842,7 @@ result)</td>
|
|
825
842
|
<h3 id="Imperative">Imperative</h3>
|
826
843
|
<p>
|
827
844
|
Instantiating conditionally and iterating collection elements are common
|
828
|
-
code generation tasks.
|
845
|
+
code generation tasks. The Imperative dialect provides these features.
|
829
846
|
</p>
|
830
847
|
|
831
848
|
<table class="ruleset">
|
@@ -838,9 +855,9 @@ code generation tasks. The Imperative dialect provides these features.
|
|
838
855
|
<tr>
|
839
856
|
<td class="signature"><tt>?{wlang/hosted}{...}{...}</tt></td>
|
840
857
|
<td class="name">conditional<br/>(third block is optional)</td>
|
841
|
-
<td class="definition">Instantiates #1, looking for an expression in the hosting language.
|
842
|
-
Evaluates it, looking for a boolean value (according to boolean semantics
|
843
|
-
of the hosting language). If true, instantiates #2, otherwise instantiates
|
858
|
+
<td class="definition">Instantiates #1, looking for an expression in the hosting language.
|
859
|
+
Evaluates it, looking for a boolean value (according to boolean semantics
|
860
|
+
of the hosting language). If true, instantiates #2, otherwise instantiates
|
844
861
|
#3 if present, returning instantiation as replacement value.</td>
|
845
862
|
</tr>
|
846
863
|
|
@@ -848,9 +865,9 @@ of the hosting language). If true, instantiates #2, otherwise instantiates
|
|
848
865
|
<td class="signature"><tt>*{wlang/hosted <as x>?}{...}{...}</tt></td>
|
849
866
|
<td class="name">enumeration<br/>(third block is optional)</td>
|
850
867
|
<td class="definition">Instantiates #1, looking for an expression in the hosting language.
|
851
|
-
Evaluates
|
852
|
-
instantiating #2 for
|
853
|
-
in the scope). If #3 is
|
868
|
+
Evaluates it, looking for an enumerable. Iterates all its elements,
|
869
|
+
instantiating #2 for each of them (the iterated value is set under name x
|
870
|
+
in the scope). If #3 is present, it is instantiated between elements.
|
854
871
|
Replacement is the concatenation of all these instantiations.</td>
|
855
872
|
</tr>
|
856
873
|
|
@@ -930,7 +947,7 @@ Replacement is the concatenation of all these instantiations.</td>
|
|
930
947
|
<p>
|
931
948
|
Complex templates come with specific needs. The ability to manipulate the
|
932
949
|
context and the current scope is provided by the Context ruleset. All are
|
933
|
-
variants of ‘saving previous instantiations’ in
|
950
|
+
variants of ‘saving previous instantiations’ in scope
|
934
951
|
variables…
|
935
952
|
</p>
|
936
953
|
|
@@ -945,10 +962,10 @@ variables…
|
|
945
962
|
<td class="signature"><tt>={wlang/hosted <as x>}{...}</tt></td>
|
946
963
|
<td class="name">assignment<br/>(second block is optional)</td>
|
947
964
|
<td class="definition">Instantiates #1, looking for an expression in the hosting language.
|
948
|
-
Evaluates
|
949
|
-
current scope with
|
965
|
+
Evaluates it, looking for any object. Without second block, expands the
|
966
|
+
current scope with ‘x’ being bound to evaluation result.
|
950
967
|
Otherwise, branches the current scope for the second block instantiation
|
951
|
-
only and bind ‘x’ the same way (i.e. x will not be
|
968
|
+
only and bind ‘x’ the same way (i.e. x will not be available
|
952
969
|
outside the second block). Returns an empty string as replacement value.</td>
|
953
970
|
</tr>
|
954
971
|
|
@@ -956,12 +973,12 @@ outside the second block). Returns an empty string as replacement value.</td>
|
|
956
973
|
<td class="signature"><tt>%={wlang/active-string <as x>}{...}{...}</tt></td>
|
957
974
|
<td class="name">modulo-assignment<br/>(third block is optional)</td>
|
958
975
|
<td class="definition">Instantiates #1, looking for a dialect qualified name. Instantiates #2
|
959
|
-
according
|
960
|
-
expands the current
|
961
|
-
instantiation. Otherwise, branches the current
|
962
|
-
instantiation only and binds ‘x’ the same way (i.e. x will
|
976
|
+
according to the rules defined by that dialect. Without third block,
|
977
|
+
expands the current scope with ‘x’ being bound to #2’s
|
978
|
+
instantiation. Otherwise, branches the current scope for the third block
|
979
|
+
instantiation only and binds ‘x’ the same way (i.e. x will not
|
963
980
|
be available outside the third block). Returns an empty string as
|
964
|
-
replacement
|
981
|
+
replacement value.</td>
|
965
982
|
</tr>
|
966
983
|
|
967
984
|
<tr>
|
@@ -1121,8 +1138,8 @@ replacement value.</td>
|
|
1121
1138
|
<h3 id="Buffering">Buffering</h3>
|
1122
1139
|
<p>
|
1123
1140
|
The Buffering ruleset is probably one of the more useful. It allows you to
|
1124
|
-
load text and data files,
|
1125
|
-
generating multiple files for example) and even to start
|
1141
|
+
load text and data files, to change the current output buffer (for
|
1142
|
+
generating multiple files for example) and even to start the instantiation
|
1126
1143
|
on other templates.
|
1127
1144
|
</p>
|
1128
1145
|
|
@@ -1136,7 +1153,7 @@ on other templates.
|
|
1136
1153
|
<tr>
|
1137
1154
|
<td class="signature"><tt><<{wlang/uri}</tt></td>
|
1138
1155
|
<td class="name">input</td>
|
1139
|
-
<td class="definition">Instantiates #1, looking for an uri. Returns the text content of the found
|
1156
|
+
<td class="definition">Instantiates #1, looking for an uri. Returns the text content of the found
|
1140
1157
|
uri (#1) as replacement value.</td>
|
1141
1158
|
</tr>
|
1142
1159
|
|
@@ -1153,10 +1170,10 @@ string as replacement value.</td>
|
|
1153
1170
|
<td class="name">data-assignment</td>
|
1154
1171
|
<td class="definition">Instantiates #1, looking for an uri. Loads data provided by this uri, based
|
1155
1172
|
on the file extension (typically .yml or .rb). Without second block,
|
1156
|
-
expands the current scope
|
1157
|
-
Otherwise, branches the current scope for the second
|
1173
|
+
expands the current scope with ‘x’ being bound to the data.
|
1174
|
+
Otherwise, branches the current scope for the second block instantiation
|
1158
1175
|
only and binds ‘x’ the same way (i.e. x will not be available
|
1159
|
-
outside
|
1176
|
+
outside the second block). Returns an empty string as replacement value.</td>
|
1160
1177
|
</tr>
|
1161
1178
|
|
1162
1179
|
<tr>
|
@@ -1186,9 +1203,9 @@ instantiation as replacement value.</td>
|
|
1186
1203
|
|
1187
1204
|
<div class="dialect">
|
1188
1205
|
<div style="margin-bottom: 20px">
|
1189
|
-
<h3 style="display: inline">wlang/
|
1206
|
+
<h3 style="display: inline">wlang/active-text</h3>
|
1190
1207
|
|
1191
|
-
<p style="display: inline">Includes Basic,
|
1208
|
+
<p style="display: inline">Includes Basic, Imperative, Buffering, Context</p>
|
1192
1209
|
|
1193
1210
|
</div>
|
1194
1211
|
|
@@ -1205,18 +1222,6 @@ instantiation as replacement value.</td>
|
|
1205
1222
|
</div>
|
1206
1223
|
|
1207
1224
|
|
1208
|
-
</div>
|
1209
|
-
|
1210
|
-
|
1211
|
-
<div class="dialect">
|
1212
|
-
<div style="margin-bottom: 20px">
|
1213
|
-
<h3 style="display: inline">wlang/active-text</h3>
|
1214
|
-
|
1215
|
-
<p style="display: inline">Includes Basic, Imperative, Buffering, Context</p>
|
1216
|
-
|
1217
|
-
</div>
|
1218
|
-
|
1219
|
-
|
1220
1225
|
</div>
|
1221
1226
|
|
1222
1227
|
|
@@ -1301,6 +1306,18 @@ instantiation as replacement value.</td>
|
|
1301
1306
|
</div>
|
1302
1307
|
|
1303
1308
|
|
1309
|
+
</div>
|
1310
|
+
|
1311
|
+
|
1312
|
+
<div class="dialect">
|
1313
|
+
<div style="margin-bottom: 20px">
|
1314
|
+
<h3 style="display: inline">wlang/hosted</h3>
|
1315
|
+
|
1316
|
+
<p style="display: inline">Includes Basic, Encoding, Imperative, Context, Hosted</p>
|
1317
|
+
|
1318
|
+
</div>
|
1319
|
+
|
1320
|
+
|
1304
1321
|
</div>
|
1305
1322
|
|
1306
1323
|
|
@@ -1344,19 +1361,19 @@ dialect</em>.</td>
|
|
1344
1361
|
<td>Basically, <em>dialect</em> is used as a synonym for (programming)
|
1345
1362
|
<em>language</em>. However <em>wlang</em> uses a tree of dialects, allowing
|
1346
1363
|
specializations: <tt>sql/sybase</tt> for example is the qualified name of a
|
1347
|
-
sub-dialect ‘sybase’ of the ‘sql’ dialect.
|
1348
|
-
come with associated <em>encoders</em>.</td>
|
1364
|
+
sub-dialect ‘sybase’ of the ‘sql’ dialect.
|
1365
|
+
Dialects come with associated <em>encoders</em>.</td>
|
1349
1366
|
<td style="font-size: 90%;"><tt>sql/sybase</tt></td>
|
1350
1367
|
</tr>
|
1351
1368
|
|
1352
1369
|
<tr>
|
1353
1370
|
<td><em>wlang dialect</em></td>
|
1354
1371
|
<td>When we talk about a <em>wlang dialect</em>, we are actually refering to
|
1355
|
-
some
|
1372
|
+
some specialization of the wlang tag-based grammar: <tt>wlang/xhtml</tt>
|
1356
1373
|
for example is the templating language <em>wlang</em> proposes to generate
|
1357
|
-
xhtml pages. An
|
1374
|
+
xhtml pages. An example of source code in that dialect has been shown
|
1358
1375
|
before. In addition to its encoders a <em>wlang dialect</em> comes with its
|
1359
|
-
sets of <em>tags</em>
|
1376
|
+
sets of <em>tags</em> and associated <em>rules</em>.</td>
|
1360
1377
|
<td style="font-size: 90%;"><tt>wlang/xhtml</tt></td>
|
1361
1378
|
</tr>
|
1362
1379
|
|
@@ -1364,7 +1381,7 @@ sets of <em>tags</em> and associated <em>rules</em>.</td>
|
|
1364
1381
|
<td><em>encoder</em></td>
|
1365
1382
|
<td>Text transformation (algorithm) applying some encoding conventions of a
|
1366
1383
|
portion of a the target language generated by a dialect. HTML
|
1367
|
-
entities-encoding, SQL’s back-quoting
|
1384
|
+
entities-encoding, SQL’s back-quoting are examples of encoders.
|
1368
1385
|
Encoders are accessible through their qualified name (dialect/encoder).</td>
|
1369
1386
|
<td style="font-size: 90%;"><tt>xhtml/entities-encoding</tt><br/><tt>sql/single-quoting</tt></td>
|
1370
1387
|
</tr>
|
@@ -1378,7 +1395,7 @@ Encoders are accessible through their qualified name (dialect/encoder).</td>
|
|
1378
1395
|
<tr>
|
1379
1396
|
<td><em>wlang tag</em></td>
|
1380
1397
|
<td>Special tags in the template, starting with wlang symbols and a number of
|
1381
|
-
wlang
|
1398
|
+
wlang blocks. A tag is associated with a wlang rule.</td>
|
1382
1399
|
<td style="font-size: 90%;"><tt>${...}</tt><br/><tt>?{...}{...}{...}</tt></td>
|
1383
1400
|
</tr>
|
1384
1401
|
|
@@ -1387,21 +1404,21 @@ wlang blocks. A tag is associated with a wlang rule.</td>
|
|
1387
1404
|
<td>Transformation semantics of a given <em>tag</em>. When wlang instantiates a
|
1388
1405
|
template it simply replaces <em>wlang tags</em> by some <em>replacement
|
1389
1406
|
value</em> (which is always a string). This value is computed by the rule
|
1390
|
-
attached to
|
1407
|
+
attached to the tag. Rule definition (see Rulesets tab on top of the page)
|
1391
1408
|
explicitly describes the number of blocks it expects, in which dialect they
|
1392
1409
|
are parsed and instantiated and the way the replacement value is computed.</td>
|
1393
1410
|
<td style="font-size: 90%;"><tt>^{wlang/active-string}{...}</tt><br/> Instantiates #1, looking for an
|
1394
|
-
encoder qualified name. Instantiates #2 in
|
1411
|
+
encoder qualified name. Instantiates #2 in the current dialect. Encode
|
1395
1412
|
#2’s instantiation using encoder found in (#1) and return the result
|
1396
1413
|
as replacement value.</td>
|
1397
1414
|
</tr>
|
1398
1415
|
|
1399
1416
|
<tr>
|
1400
1417
|
<td><em>context</em></td>
|
1401
|
-
<td>Some rules allow code to be executed in the <em>hosting language</em> (the
|
1418
|
+
<td>Some rules allow code to be executed in the <em>hosting language</em> (the
|
1402
1419
|
definition explicitly announce it by putting <tt>wlang/hosted</tt> in the
|
1403
1420
|
corresponding block). When doing so, this code is in fact executed in a
|
1404
|
-
given context that
|
1421
|
+
given context that provides the execution semantics.</td>
|
1405
1422
|
<td style="font-size: 90%;"></td>
|
1406
1423
|
</tr>
|
1407
1424
|
|
@@ -1656,5 +1673,18 @@ for example). See the ‘Hosting language’ section to learn more.</td>
|
|
1656
1673
|
|
1657
1674
|
</div>
|
1658
1675
|
|
1676
|
+
<script type="text/javascript">
|
1677
|
+
|
1678
|
+
var _gaq = _gaq || [];
|
1679
|
+
_gaq.push(['_setAccount', 'UA-16520635-3']);
|
1680
|
+
_gaq.push(['_trackPageview']);
|
1681
|
+
|
1682
|
+
(function() {
|
1683
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
1684
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
1685
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
1686
|
+
})();
|
1687
|
+
|
1688
|
+
</script>
|
1659
1689
|
</body>
|
1660
1690
|
</html>
|