wlang 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +96 -0
- data/{LICENCE.rdoc → LICENCE.md} +2 -2
- data/README.md +176 -0
- data/bin/wlang +1 -0
- data/doc/specification/dialects.wtpl +1 -1
- data/doc/specification/specification.html +1237 -1001
- data/doc/specification/specification.yml +12 -10
- data/lib/wlang.rb +2 -2
- data/lib/wlang/dialects/coderay_dialect.rb +1 -0
- data/lib/wlang/dialects/hosted_dialect.rb +50 -0
- data/lib/wlang/dialects/plain_text_dialect.rb +2 -2
- data/lib/wlang/dialects/ruby_dialect.rb +74 -5
- data/lib/wlang/dialects/standard_dialects.rb +41 -0
- data/lib/wlang/dialects/yaml_dialect.rb +30 -0
- data/lib/wlang/encoder.rb +0 -4
- data/lib/wlang/ext/string.rb +7 -2
- data/lib/wlang/parser.rb +1 -1
- data/lib/wlang/rulesets/basic_ruleset.rb +1 -1
- data/lib/wlang/rulesets/context_ruleset.rb +3 -3
- data/lib/wlang/rulesets/encoding_ruleset.rb +3 -3
- data/lib/wlang/rulesets/imperative_ruleset.rb +2 -2
- data/test/spec/test_all.rb +1 -1
- data/test/standard_dialects/ruby/data.rb +7 -0
- data/test/standard_dialects/ruby/inclusion.exp +6 -0
- data/test/standard_dialects/ruby/inclusion.tpl +6 -0
- data/test/standard_dialects/test_all.rb +29 -0
- data/test/standard_dialects/yaml/assumptions_test.rb +13 -0
- data/test/standard_dialects/yaml/data.rb +3 -0
- data/test/standard_dialects/yaml/inclusion_1.exp +7 -0
- data/test/standard_dialects/yaml/inclusion_1.tpl +2 -0
- data/test/standard_dialects/yaml/inclusion_2.exp +5 -0
- data/test/standard_dialects/yaml/inclusion_2.tpl +3 -0
- data/test/unit/wlang/ruby_dialect_test.rb +1 -1
- metadata +23 -11
- data/CHANGELOG.rdoc +0 -73
- data/README.rdoc +0 -165
data/CHANGELOG.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Version 0.10.0
|
2
|
+
|
3
|
+
## New features
|
4
|
+
|
5
|
+
* Introduced a wlang/hosted language which parses blocks as actually described in the specification
|
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
|
10
|
+
|
11
|
+
## Broken features and APIs
|
12
|
+
|
13
|
+
* Due to the wlang/ruby <-> wlang/hosted changes and the fact that wlang/ruby now includes the
|
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.
|
19
|
+
|
20
|
+
## Development-based changesets
|
21
|
+
|
22
|
+
* Moved to rspec 2.4.0
|
23
|
+
* Moved from rdoc to yard for generating the documentation
|
24
|
+
* README, CHANGELOG and LICENCE are now in Mardown instead of rdoc
|
25
|
+
|
26
|
+
# Version 0.9.2
|
27
|
+
|
28
|
+
## New features (by order of importance)
|
29
|
+
|
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
|
33
|
+
|
34
|
+
# Version 0.9.1
|
35
|
+
|
36
|
+
## Bug fixes
|
37
|
+
|
38
|
+
* #307, about HashScope.has_key? which returned nil instead of false in some situations
|
39
|
+
|
40
|
+
## Broken features and APIs (by order of importance)
|
41
|
+
|
42
|
+
* HostedLanguage::DSL is strictly private and should be reopened. Methods added to this class
|
43
|
+
will never be available in templates. Use HostedLanguage.variable_missing instead.
|
44
|
+
* ::WLang::BasicObject has been removed. HostedLanguage::DSL implements its own strategy, which
|
45
|
+
is spec tested in test/spec/basic_object.spec
|
46
|
+
|
47
|
+
## New features (by order of importance)
|
48
|
+
|
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
|
53
|
+
|
54
|
+
# Version 0.9.0
|
55
|
+
|
56
|
+
## Broken features and APIs (by order of importance)
|
57
|
+
|
58
|
+
* Major broken API in WLang.instantiate and WLang.file_instantiate which do not allow passing
|
59
|
+
buffers anymore
|
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
|
+
found in the current template scope (0.8.x versions returned nil in this case)
|
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
|
+
## New features (by order of importance)
|
70
|
+
|
71
|
+
* WLang::HostingLanguage introduced, with a default one for Ruby. The hosting language
|
72
|
+
is the way to provide a main scope, accessible to all templates at once.
|
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
|
84
|
+
|
85
|
+
# Version 0.8.5
|
86
|
+
|
87
|
+
* Enhances error messages a lot
|
88
|
+
* Some bug fixes for ruby 0.8.7
|
89
|
+
|
90
|
+
# Version 0.8.4
|
91
|
+
|
92
|
+
* Migration from svn.chefbe.net to github.com
|
93
|
+
|
94
|
+
# Version 0.8.0
|
95
|
+
|
96
|
+
* First public version
|
data/{LICENCE.rdoc → LICENCE.md}
RENAMED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
# Licence
|
2
2
|
|
3
3
|
The MIT License
|
4
4
|
|
5
|
-
Copyright (c) 2009 Bernard & Louis Lambeau and the University of Louvain
|
5
|
+
Copyright (c) 2009-2011 Bernard & Louis Lambeau and the University of Louvain
|
6
6
|
(Universite Catholique de Louvain, Louvain-la-Neuve, Belgium)
|
7
7
|
|
8
8
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
data/README.md
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
# What is _wlang_ ?
|
2
|
+
|
3
|
+
_wlang_ is a simple, powerful, robust and secure <b>code generation</b>/<b>templating engine</b>
|
4
|
+
(at least, authors hope so ;-) Motivation for it can be found at http://www.revision-zero.org/wlang.
|
5
|
+
It's main aim is to help you creating web pages, sql queries, ruby code (that is, generating code in
|
6
|
+
general) without having to worry too much about html entities encoding, sql back quoting, string
|
7
|
+
escaping and the like. WLang proposes a generic engine that you can extend to fit your needs. It also
|
8
|
+
proposes standard instantiations of this engine for common tasks such as creating SQL queries,
|
9
|
+
instantiating web pages, etc.
|
10
|
+
|
11
|
+
Basic concepts and usage is illustrated below. Also have a look at the [detailed specification](http://blambeau.github.com/wlang).
|
12
|
+
|
13
|
+
## A collection of typical encoders
|
14
|
+
|
15
|
+
The first basic usage of WLang is to provide a collection of text encoders:
|
16
|
+
|
17
|
+
WLang::encode('&', 'xhtml/entities-encoding') # &
|
18
|
+
WLang::encode("O'Neil", 'sql/single-quoting') # O\'Neil
|
19
|
+
WLang::encode("O'Neil", 'sql/sybase/single-quoting') # O''Neil
|
20
|
+
...
|
21
|
+
WLang::encode("hello world", 'plain-text/camel') # HelloWorld
|
22
|
+
WLang::encode("hello world", 'plain-text/lower-camel') # helloWorld
|
23
|
+
...
|
24
|
+
WLang::encode("helloWorld", 'ruby/method-case') # hello_world
|
25
|
+
|
26
|
+
## A powerful alternative to ruby string interpolation
|
27
|
+
|
28
|
+
The second usage is to have shortcuts for using these encoders in typical
|
29
|
+
situations:
|
30
|
+
|
31
|
+
# Hello world!
|
32
|
+
"Hello ${who}!".wlang(:who => 'world')
|
33
|
+
|
34
|
+
# Hello cruel & world!
|
35
|
+
"Hello ${who}!".wlang({:who => 'cruel & world'}, 'wlang/xhtml')
|
36
|
+
|
37
|
+
# Hello blambeau, llambeau
|
38
|
+
"Hello *{authors as a}{${a}}{, }".wlang(:authors => ['blambeau', 'llambeau'])
|
39
|
+
|
40
|
+
# INSERT INTO people VALUES ('O\'Neil')
|
41
|
+
INSERT INTO people VALUES ('{who}')".wlang(:who => "O'Neil")
|
42
|
+
|
43
|
+
## A powerful templating engine
|
44
|
+
|
45
|
+
But the main usage of _wlang_ is as follows (for bold words, see terminology later):
|
46
|
+
you have a *template* file (written in a given _wlang_ *dialect*), you have some
|
47
|
+
instantiation *context* (data provided through a Ruby Hash or a yaml file for
|
48
|
+
example) and you would like to instantiate the template with that data.
|
49
|
+
|
50
|
+
Example: a template.whtml as follows
|
51
|
+
<html>
|
52
|
+
<head>
|
53
|
+
<title>${title}</title>
|
54
|
+
</head>
|
55
|
+
<body>
|
56
|
+
<h1>Hello ${who} !</h1>
|
57
|
+
</body>
|
58
|
+
</html>
|
59
|
+
|
60
|
+
Instantiation data is a hash containing values for _title_ and _who_. Instantiating
|
61
|
+
the template is straightforward:
|
62
|
+
|
63
|
+
require 'wlang'
|
64
|
+
context = {"title" => "Hello world in WLang", "who" => "Alice"}
|
65
|
+
STDOUT << WLang.file_instantiate("template.whtml", context)
|
66
|
+
|
67
|
+
## Behind the scene
|
68
|
+
|
69
|
+
- WLang helps you avoiding SQL injection and XSS attacks through the same tags reacting differently
|
70
|
+
in different contexts.
|
71
|
+
- WLang understands your context (and its dialect) from the template file extension
|
72
|
+
- WLang provides a rich collection of pre-defined tags and dialects
|
73
|
+
- WLang allows you to create your own encoders, tags and dialects while reusing existing ones
|
74
|
+
- WLang may change the current dialect during the template instantiation itself (generating
|
75
|
+
html with embedded javascript is easy and natural)
|
76
|
+
- WLang is able to generate wlang code without any perturabation
|
77
|
+
|
78
|
+
## Additional examples (availability of the tags may depend on the dialect)
|
79
|
+
|
80
|
+
* Include text files on the fly
|
81
|
+
|
82
|
+
<<{my_file.html}
|
83
|
+
|
84
|
+
* Instantiate sub-templates on the fly, passing data as arguments
|
85
|
+
|
86
|
+
<<+{my_sub_template.whtml using who: 'wlang'}
|
87
|
+
|
88
|
+
* Load data from yaml or ruby files on the fly
|
89
|
+
|
90
|
+
<<={resources.yaml as resources}{
|
91
|
+
*{resources as r}{ ${r} }
|
92
|
+
}
|
93
|
+
|
94
|
+
* WLang instrospection (basic example)
|
95
|
+
|
96
|
+
context = {:varname => 'who', :who => 'wlang'}
|
97
|
+
"Hello ${${varname}}!".wlang(context) # => Hello wlang!
|
98
|
+
|
99
|
+
* Generate a wlang template and instantiate it after that
|
100
|
+
|
101
|
+
dialect = 'wlang/active-string'
|
102
|
+
tpl = "Hello $(${varname})!" # => Hello $(${varname})
|
103
|
+
tpl = tpl.wlang(:varname => 'who') # => Hello $(who)!
|
104
|
+
tpl = tpl.wlang({:who => 'wlang'}, dialect, :parentheses) # => Hello wlang!
|
105
|
+
|
106
|
+
## Roadmap
|
107
|
+
|
108
|
+
- For terminology and a quick overview of _wlang_ for generating code, read on.
|
109
|
+
- For the current cheatsheet/specification see the file doc/specification/specification.html
|
110
|
+
- If you want to learn _wlang_ quickly, see the example directory or read examples
|
111
|
+
in the specification file (if you understand all examples in the specification file, then you
|
112
|
+
probably master wlang.
|
113
|
+
- If you want a killer example (but simple) see the way the specification.html file
|
114
|
+
is generated in doc/specification directory
|
115
|
+
- If you want to know which dialects are available (that is, in which target languages
|
116
|
+
you can generate code), see the specification as well or read the file
|
117
|
+
lib/wlang/dialects/standard_dialects.rb in the source distribution.
|
118
|
+
- If you want to create your own wlang dialect, see WLang::Dialect::DSL
|
119
|
+
- If you think that your own dialect is of generic purpose and well-designed, if
|
120
|
+
you have any question or want to contribute join us on {github}[http://github.com/blambeau/wlang].
|
121
|
+
|
122
|
+
## Terminology
|
123
|
+
|
124
|
+
_wlang_ comes with a well-defined terminology for the underlying abstractions. As
|
125
|
+
the documentation uses it, you'll probably be happy to learn about the main abstractions
|
126
|
+
and associated terms.
|
127
|
+
|
128
|
+
_template_ : Source code respecting the wlang grammar, and attached to a given <em>wlang
|
129
|
+
dialect</em>. Asbtraction implemented by WLang::Template.
|
130
|
+
|
131
|
+
_dialect_ : Basically, <em>dialect</em> is used as a synonym for (programming) <em>language</em>.
|
132
|
+
However _wlang_ uses a tree of dialects, allowing specializations: <tt>sql/sybase</tt>
|
133
|
+
for example is the qualified name of a sub-dialect 'sybase' of the 'sql' dialect.
|
134
|
+
Dialects come with associated _encoders_. Abstraction implemented by WLang::Dialect.
|
135
|
+
|
136
|
+
_wlang dialect_ : When we talk about a <em>wlang dialect</em>, we are actually refering to some
|
137
|
+
specialization of the wlang tag-based grammar: <tt>wlang/xhtml</tt> for example
|
138
|
+
is the templating language _wlang_ proposes to generate xhtml pages. An
|
139
|
+
example of source code in that dialect has been shown before.
|
140
|
+
In addition to its encoders a <em>wlang dialect</em> comes with its sets of _tags_
|
141
|
+
and associated _rules_. Abstraction implemented by WLang::Dialect as well as
|
142
|
+
WLang::EncoderSet and WLang::RuleSet.
|
143
|
+
|
144
|
+
_encoder set_ : Reusable set of <em>encoders</em>, attached to a dialect. Abstraction
|
145
|
+
implemented by WLang::EncoderSet.
|
146
|
+
|
147
|
+
_encoder_ : Text transformation (algorithm) applying some encoding conventions of a portion
|
148
|
+
of a the target language generated by a dialect. HTML entities-encoding, SQL's back-quoting
|
149
|
+
are examples of encoders. Encoders are accessible through their qualified name:
|
150
|
+
xhtml/entities-encoding and sql/back-quoting in the examples. Abstraction implemented by
|
151
|
+
WLang::Encoder.
|
152
|
+
|
153
|
+
_ruleset_ : Reusable set of <em>tags</em> associated to <em>rule</em>s. Abstraction
|
154
|
+
implemented by WLang::RuleSet.
|
155
|
+
|
156
|
+
_wlang tag_ : Special tags in the template, starting with wlang symbols and a number of wlang
|
157
|
+
blocks. A tag is associated with a wlang rule. Examples: <tt>${...}</tt> is a
|
158
|
+
tag with only one block, while <tt>?{...}{...}{...}</tt> is another tag but with
|
159
|
+
three blocks.
|
160
|
+
|
161
|
+
_rule_ : Transformation semantics of a given <em>tag</em>. When wlang instantiates a
|
162
|
+
template it simply replaces <em>wlang tags</em> by some <em>replacement value</em>
|
163
|
+
(which is always a string). This value is computed by the rule attached to
|
164
|
+
the tag. Rule definition explicitly describes the number of blocks it expects, in which dialect they
|
165
|
+
are parsed and instantiated and the way the replacement value is computed.
|
166
|
+
Example: <tt>^{wlang/active-string}{...}</tt> (also known as 'encoding')
|
167
|
+
instantiates #1, looking for an encoder qualified name. Instantiates #2 in
|
168
|
+
the current dialect. Encode #2's instantiation using encoder found in (#1)
|
169
|
+
|
170
|
+
_context_ : Some rules allow code to be executed in the <em>hosting language</em> (the
|
171
|
+
definition explicitly announce it by putting <tt>wlang/hosted</tt> in the corresponding
|
172
|
+
block). When doing so, this code is in fact executed in a given context that
|
173
|
+
provides the execution semantics. Abstraction implemented in WLang::Parser::Context.
|
174
|
+
|
175
|
+
_hosting language_ : language (or framework) that executes wlang. In this case, it will be
|
176
|
+
<tt>ruby</tt>.
|
data/bin/wlang
CHANGED
@@ -3,517 +3,539 @@
|
|
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.
|
6
|
+
<title>WLang (version 0.10.0)</title>
|
7
7
|
<style type="text/css">
|
8
8
|
body {
|
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
|
-
|
9
|
+
font-family: arial, verdana, sans-serif;
|
10
|
+
font-size: 14px;
|
11
|
+
width: 1024px;
|
12
|
+
margin: auto;
|
13
|
+
margin-top: 20px;
|
14
|
+
}
|
15
|
+
.clear { clear: both; }
|
16
|
+
p { margin: 0px; margin-bottom: 10px; text-align: justify; }
|
17
|
+
#title { float: left; margin: 10px 0px 20px 0px; }
|
18
|
+
#tabs { float: right; margin: 15px 0px; }
|
19
|
+
#tabs li { display: block; float: right; cursor: pointer; margin: 0px 0px 0px 5px; padding: 5px; border: 1px solid black; }
|
20
|
+
#tabs li.focus { background-color: #A00000; color: white; }
|
21
|
+
dl dt { margin-top: 10px; font-weight: bold; }
|
22
|
+
div.header { border-bottom: 1px solid black; margin: 10px 0px; }
|
23
|
+
h2 { float: left; margin: 0px; padding: 0px; }
|
24
|
+
h3 { margin-top: 20px; margin-bottom: 10px; text-decoration: underline;}
|
25
|
+
dl { padding-left: 35px; }
|
26
|
+
ul { padding: 0px 0px 0px 25px; }
|
27
|
+
ul li { margin: 5px;}
|
28
|
+
ul.links { float: right; margin: 0px; padding: 0px; }
|
29
|
+
ul.links li { cursor: pointer; margin: 0px 0px 0px 10px; padding: 0px; padding-top: 5px; display: block; float: right; }
|
30
|
+
ul.links li a, ul.links li a:visited { color: black; text-decoration: none; }
|
31
|
+
ul.links li a:hover { color: #A00000; }
|
32
|
+
h3 { margin-bottom: 5px; }
|
33
|
+
h4 { margin-bottom: 3px; float: left; margin-top: 0px; }
|
34
|
+
table { border-collapse: collapse; border: 1px solid black; }
|
35
|
+
table th { font-size: 12px; }
|
36
|
+
table th, table td { padding: 4px; }
|
37
|
+
table.glossary { margin-top: 20px; }
|
38
|
+
table.glossary th { background: green; color: white; border-bottom: 1px solid black; }
|
39
|
+
table.glossary th.term { width: 100px; }
|
40
|
+
table.glossary td { border-bottom: 1px dashed black; }
|
41
|
+
table.symbols { font-size: 12px; margin-top: 20px; width: 100%; }
|
42
|
+
table.symbols th { background: green; color: white; border-bottom: 1px solid black; }
|
43
|
+
table.symbols th.name { width: 150px; }
|
44
|
+
table.symbols th.symbol { width: 50px; }
|
45
|
+
table.symbols th.meaning { width: 250px; }
|
46
|
+
table.symbols td { border-bottom: 1px dashed black; }
|
47
|
+
table.ruleset { font-size: 12px; }
|
48
|
+
table.ruleset th { background: green; color: white; }
|
49
|
+
table.ruleset td { border-bottom: 1px dashed black; }
|
50
|
+
th.signature, td.signature { width: 300px; }
|
51
|
+
th.name, td.name { width: 120px; }
|
52
|
+
th.definition, td.definition { width: 580px; }
|
53
|
+
table.examples { float: right; font-size: 12px; }
|
54
|
+
table.examples th { background: #A00000; color: white; border-bottom: 1px solid black; }
|
55
|
+
table.examples th, table.examples td { padding: 4px; }
|
56
|
+
table.examples td { border-bottom: 1px dashed black; }
|
57
|
+
th.dialect, td.dialect { width: 150px; }
|
58
|
+
th.expression, td.expression { width: 350px; }
|
59
|
+
th.replacement, td.replacement { width: 350px; }
|
60
|
+
div.dialect {padding-left: 20px;}
|
61
61
|
</style>
|
62
62
|
<script type="text/javascript" language="JavaScript"><!--
|
63
63
|
var current = 'about'
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
function show(who) {
|
65
|
+
document.getElementById(current).style.display = "none";
|
66
|
+
document.getElementById(current + 'focus').className = "unfocus";
|
67
|
+
document.getElementById(who).style.display = "block";
|
68
|
+
document.getElementById(who + 'focus').className = "focus";
|
69
|
+
current = who;
|
70
|
+
}
|
71
71
|
|
72
72
|
//--></script>
|
73
73
|
</head>
|
74
74
|
<body onload="show('about')">
|
75
|
-
<h1 id="title">WLang (version 0.
|
75
|
+
<h1 id="title">WLang (version 0.10.0)</h1>
|
76
76
|
<ul id="tabs">
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
|
78
|
+
<li id="symbolsfocus" onclick="show('symbols')">Tag symbols</li>
|
79
|
+
|
80
|
+
<li id="glossaryfocus" onclick="show('glossary')">Glossary</li>
|
81
|
+
|
82
|
+
<li id="hostingfocus" onclick="show('hosting')">Hosting language</li>
|
83
|
+
|
84
|
+
<li id="dialectsfocus" onclick="show('dialects')">Dialects</li>
|
85
|
+
|
86
|
+
<li id="rulesetsfocus" onclick="show('rulesets')">Rulesets</li>
|
87
|
+
|
88
|
+
<li id="overviewfocus" onclick="show('overview')">Overview</li>
|
89
|
+
|
90
|
+
<li id="aboutfocus" onclick="show('about')">About</li>
|
91
|
+
|
85
92
|
</ul>
|
86
93
|
<div class="clear"></div>
|
87
|
-
<div id="about" style="display: none;">
|
88
|
-
<div class="header">
|
89
|
-
<h2>About</h2>
|
90
|
-
|
91
|
-
<div class="clear"></div>
|
92
|
-
</div>
|
93
|
-
<p>
|
94
|
-
WLang is a a reusable and extensible <em>code generator</em>, also known as
|
95
|
-
a <em>templating engine</em>. Motivation for it can be found at <a
|
96
|
-
href="http://www.revision-zero.org/wlang">www.revision-zero.org/wlang</a>.
|
97
|
-
The current file is the reference of the tool.
|
98
|
-
</p>
|
99
|
-
<h3>Topics</h3>
|
100
|
-
<dl>
|
101
|
-
<dt>Short overview</dt><dd>Probably the first section to read! Basic usage of <em>wlang</em> is
|
102
|
-
explained here and pointers are given to continue your learning.
|
103
|
-
|
104
|
-
</dd>
|
105
|
-
<dt>Rulesets</dt><dd>Standard rulesets are specified. As most of them are included in standard
|
106
|
-
dialects, looking at standard rulesets is the quickest way to learn all of
|
107
|
-
them at once.
|
108
|
-
|
109
|
-
</dd>
|
110
|
-
<dt>Dialects</dt><dd>Standard dialects are described. This page also provides useful cheatsheets
|
111
|
-
of available tags in standard dialects.
|
112
|
-
|
113
|
-
</dd>
|
114
|
-
<dt>Hosting language</dt><dd>Somewhat more tricky but powerful. The notion of hosting language is
|
115
|
-
explained more deeply. Implementing you own hosting language abstraction
|
116
|
-
(advanced topic) sometimes leads to cleaner and cross-implementation
|
117
|
-
templates.
|
118
|
-
|
119
|
-
</dd>
|
120
|
-
<dt>Glossary</dt><dd><em>wlang</em> comes with a terminology, knowing it will make your reading
|
121
|
-
easier.
|
122
|
-
|
123
|
-
</dd>
|
124
|
-
<dt>Symbols</dt><dd>If you plan to create your own tags, it can be useful to know what is
|
125
|
-
allowed and what is not. This pages covers this topic.
|
126
|
-
|
127
|
-
</dd>
|
128
|
-
</dl>
|
129
|
-
<h3>About this document</h3>
|
130
|
-
<p>
|
131
|
-
This document is a simple .html file without external dependencies
|
132
|
-
(embedded CSS and javascript). As it contains several cheatsheets, you can
|
133
|
-
simply save it on your harddisk without having to be online to browse the
|
134
|
-
documentation. It has been generated using <em>wlang</em> itself using the
|
135
|
-
following command:
|
136
|
-
</p>
|
137
|
-
<pre>
|
138
|
-
wlang specification.wtpl
|
139
|
-
</pre>
|
140
|
-
<p>
|
141
|
-
The file ‘specification.wtpl’ is almost empty and other files
|
142
|
-
next to it are all kept simple and written in the most appropriate format
|
143
|
-
for the task at hand (YAML for structured parts, RDoc for text sections,
|
144
|
-
sometimes YAML embedding short sentences writted in RDoc style, etc.). One
|
145
|
-
way to learn <em>wlang</em> quickly is to download the source distribution
|
146
|
-
and to look how this is made possible ;-)
|
147
|
-
</p>
|
148
|
-
<p>
|
149
|
-
This reference document is under a <a
|
150
|
-
href="http://creativecommons.org/licenses/by/2.0/be/">Creative Commons
|
151
|
-
Licence 2.0</a> contract. You can use it, redistribute it and modify it
|
152
|
-
providing that you keep a reference to the original licensor (namely, the
|
153
|
-
‘University of Louvain’ or ‘Bernard and Louis
|
154
|
-
Lambeau’).
|
155
|
-
</p>
|
156
|
-
<p>
|
157
|
-
Enjoy <em>wlang</em> !
|
158
|
-
</p>
|
159
|
-
<h3>Distribution</h3>
|
160
|
-
<ul>
|
161
|
-
<li>The reference implementation of <em>wlang</em>, implemented in Ruby, is
|
162
|
-
freely available as a ‘wlang’ gem (under MIT licence). <br/>
|
163
|
-
Use <tt>'gem install wlang'</tt> to install it. For repository and bug
|
164
|
-
tracker visit us on <a href="http://github.com/blambeau/wlang">github</a>
|
165
|
-
|
166
|
-
</li>
|
167
|
-
<li>We don’t have another implementation up to now. If you plan to start
|
168
|
-
one in another language, let us know!
|
169
94
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
}</tt> that will be replaced by <tt>'Short overview of wlang'</tt> and
|
280
|
-
<tt>'blambeau, llambeau, ancailliau'</tt>, respectively. A lot of tags is
|
281
|
-
available, each of them being designed for a specific task: inserting the
|
282
|
-
value of a variable, iterating over collections, including another file,
|
283
|
-
dynamically loading instantiation data, etc. All of these things are
|
284
|
-
commonly proposed by templating engines and <em>wlang</em> is one of them
|
285
|
-
… However, <em>wlang</em> is a bit different as will quickly appear.
|
286
|
-
</p>
|
287
|
-
<p>
|
288
|
-
Indeed (and maybe surprisingly) <em>wlang</em> can also behave really
|
289
|
-
differently on the same template: replacing <tt>${title}</tt> but not
|
290
|
-
<tt>*{...}</tt> or the converse, or not replacing anything, or replacing
|
291
|
-
both tags but not <tt>${who}</tt>, etc. All of this is possible in
|
292
|
-
<em>wlang</em>. The magic relies under the notion of <em>dialect</em>,
|
293
|
-
which you need to understand.
|
294
|
-
</p>
|
295
|
-
<h3>Dialects and Rulesets</h3>
|
296
|
-
<p>
|
297
|
-
The notion of dialect drives the recognition of tags as well as their
|
298
|
-
replacement during instantiation. Dialects are what makes <em>wlang</em>
|
299
|
-
really powerful: if instantiated as being written in the
|
300
|
-
<tt>wlang/xhtml</tt> dialect, the template above will give the result
|
301
|
-
mentionned previously. In contrast, if written in <tt>wlang/dummy</tt> the
|
302
|
-
template will be reproduced whitout any change (no tag replacement at all).
|
303
|
-
This behavior is not hardcoded; it results from the definition of wlang
|
304
|
-
(standard) dialects: <tt>wlang/xhtml</tt> define special meanings for
|
305
|
-
<tt>${...}</tt> and <tt>*{...}{...}{...}</tt> while <tt>wlang/dummy</tt>
|
306
|
-
does not.
|
307
|
-
</p>
|
308
|
-
<p>
|
309
|
-
The replacement of a given <em>tag</em> during instantiation is computed by
|
310
|
-
what we call the <em>rule</em> attached to the tag (keeping rules and tags
|
311
|
-
as different concepts leads to another feature of <em>wlang</em>: you can
|
312
|
-
reuse rule implementations and attach them to other tags than those
|
313
|
-
proposed). A dialect comes with a set of (tag, rule) pairs that determine
|
314
|
-
its replacement behavior. Such a set is called a <em>ruleset</em>; for
|
315
|
-
easier reuse, standard rulesets are already implemented. A dialect is a
|
316
|
-
packaging of standard rulesets (and maybe implements specific tag/rule
|
317
|
-
pairs) designed for generating code in a given target language.
|
318
|
-
</p>
|
319
|
-
<p>
|
320
|
-
A complete <em>wlang</em> implementation already provides standard dialects
|
321
|
-
for common tasks: creating html pages, building SQL queries, generating
|
322
|
-
code in Ruby or in another language, etc. Each dialect comes with special
|
323
|
-
tags that are useful for the task at hand (a tag for back-quoting values is
|
324
|
-
useful for creating SQL queries but does not really makes sense for
|
325
|
-
generating an html page where, in contrast, a tag for encoding entities is
|
326
|
-
probably welcome). Such an implementation also allows you to extend
|
327
|
-
standard dialects and to create your own dialect by implementing specific
|
328
|
-
tags and rules or by reusing existing ones. Lastlty, the dialect in used
|
329
|
-
during instantiation can be changed dynamically (<em>explicitly</em>, by
|
330
|
-
using the <tt>%{dialect/qualified/name}{...}</tt> standard tag and
|
331
|
-
<em>implicitly</em>, when rules parse their blocks).
|
332
|
-
</p>
|
333
|
-
<p>
|
334
|
-
To learn more about standard dialects and reusable rules, read the
|
335
|
-
‘Dialects’ and ‘Rulesets’ pages of this
|
336
|
-
documentation.
|
337
|
-
</p>
|
338
|
-
<h3>Grammar</h3>
|
339
|
-
<p>
|
340
|
-
The (abstract) <em>wlang</em> grammar rules what forms a valid template. At
|
341
|
-
first glance, this grammar does not depend on the dialect that is used for
|
342
|
-
instantiation. It is simple, but comes with some constraints that are
|
343
|
-
explained below:
|
344
|
-
</p>
|
345
|
-
<ul>
|
346
|
-
<li>block delimiters are ’{’ and ’}’ by default;
|
347
|
-
<em>wlang</em> can be configured to use ’(’ and ’)’
|
348
|
-
or ’[’ and ’]’ instead. However, block
|
349
|
-
<b>delimiters are template-specific</b>: only one kind of delimiters can be
|
350
|
-
used inside the same template.
|
351
|
-
|
352
|
-
</li>
|
353
|
-
<li>block delimiters <b>must always be paired</b>, even when not used for
|
354
|
-
delimiting blocks. If an opening or closing delimiter is not paired, it
|
355
|
-
must be escaped with a backslash, which will not be reproduced. If you want
|
356
|
-
a backslash to appear before a block delimiter in the instantiation result,
|
357
|
-
use a double backslash.
|
358
|
-
|
359
|
-
</li>
|
360
|
-
<li>if a given tag has a special meaning in the current dialect and you
|
361
|
-
don’t want it to be replaced by <em>wlang</em> you can escape it with
|
362
|
-
a backslash as well (the backslash will not be reproduced).
|
363
|
-
|
364
|
-
</li>
|
365
|
-
<li>some tags (precisely: some rules associated with tags) require multiple
|
366
|
-
blocks (like <tt>*{...}{...}{...}</tt> in <tt>wlang/xhtml</tt> for example,
|
367
|
-
with the third block bein optional). In such a case no character is allowed
|
368
|
-
between the end of a block ’}’ and the start of the next one
|
369
|
-
’{’, not even spaces or a carriage return. In other words,
|
370
|
-
multiple blocks (that must be interpreted as such) must touch each others
|
371
|
-
using ’}{’ precisely, as ilustrated below. If a non-optional
|
372
|
-
block is missing a parse error is raised by the <em>wlang</em>
|
373
|
-
implementation.
|
374
|
-
|
375
|
-
<pre>
|
376
|
-
*{authors as who}{${who}}{, } -> blambeau, llambeau, ancailliau
|
377
|
-
*{authors as who}{${who}} {, } -> blambeaullambeauancailliau {, }
|
378
|
-
*{authors as who} {${who}}{, } -> parse error 1:18, missing block 2 in *{...}{...}
|
379
|
-
</pre>
|
380
|
-
</li>
|
381
|
-
</ul>
|
382
|
-
<p>
|
383
|
-
In addition to these constraints, dialects and the hosting language may
|
384
|
-
impose restrictions on what can be put inside specific blocks of tags/rules
|
385
|
-
(for example, ‘authors as who’ is valid as first tag of
|
386
|
-
<tt>*{...}{...}</tt> but not every string is, of course). These constraints
|
387
|
-
are not specific to the wlang grammar <em>per se</em> and are explained in
|
388
|
-
the ‘Rulesets’, ‘Dialects’ and ‘Hosting
|
389
|
-
language’ pages of this document.
|
390
|
-
</p>
|
391
|
-
|
392
|
-
|
393
|
-
</div>
|
394
|
-
<div id="rulesets" style="display: none;">
|
395
|
-
<div class="header">
|
396
|
-
<h2>Rulesets</h2>
|
397
|
-
<ul class="links">
|
398
|
-
<li><a href="#Buffering">Buffering</a></li><li><a href="#Context">Context</a></li><li><a href="#Imperative">Imperative</a></li><li><a href="#Encoding">Encoding</a></li><li><a href="#Basic">Basic</a></li>
|
399
|
-
</ul>
|
400
|
-
|
401
|
-
<div class="clear"></div>
|
402
|
-
</div>
|
403
|
-
<p>
|
404
|
-
Standard ruleset are designed to be reusable: including them in your own
|
405
|
-
dialect is made easy by a typical <em>wlang</em> implementation. Some of
|
406
|
-
them are also included by standard dialects.
|
407
|
-
</p>
|
408
|
-
<h3>How to read this cheatsheet?</h3>
|
409
|
-
<p>
|
410
|
-
First of all, focus on the examples; they are written to let you learn
|
411
|
-
<em>wlang</em> quickly and deeply. Some of them are a bit difficult to
|
412
|
-
understand but they are representative of <em>wlang</em> powerfulness
|
413
|
-
(don’t be affraid: in practice, some constructions are never used).
|
414
|
-
Don’t forget that the <tt>wlang/dummy</tt> dialect does not recognize
|
415
|
-
any tag. We also assume instantiation data to be the following hash:
|
416
|
-
</p>
|
417
|
-
<pre>
|
418
|
-
{"name" => "O'Neil",
|
419
|
-
"author" => "blambeau"
|
420
|
-
"authors" => ["blambeau", "llambeau", "ancailliau"]}
|
421
|
-
</pre>
|
422
|
-
<p>
|
423
|
-
Moreover, the dialect column in the examples is important; <em>wlang</em>
|
424
|
-
behaves differently in different dialects. When the dialect does not care,
|
425
|
-
we use <tt>wlang/*</tt> which means ‘in any dialect that includes
|
426
|
-
this ruleset’.
|
427
|
-
</p>
|
428
|
-
<p>
|
429
|
-
Next, certain rule definitions are given as shortcuts for longer
|
430
|
-
expressions, involving other tags. This is somewhat representative of
|
431
|
-
<em>wlang</em> usage, even if these rules are not actually implemented this
|
432
|
-
way (mainly for efficiency concerns). Once again, understanding shortcuts
|
433
|
-
will help you mastering wlang! In definitions (textual as well as
|
434
|
-
shortcuts), we use #1, #2, and #3 to refer to the content of the blocks.
|
435
|
-
Those identifiers are not real <em>wlang</em> constructs, but are only used
|
436
|
-
here for easier explanations (for those who know this kind of vocabulary:
|
437
|
-
they are part of the meta-language, not the language <em>per se</em>).
|
438
|
-
</p>
|
439
|
-
<p>
|
440
|
-
Lastly, dialect names that appear in rule signatures are to be interpreted
|
441
|
-
as an implicit dialect modulation: the corresponding block (often the first
|
442
|
-
one) is not instantiated in the current dialect but in the one specified by
|
443
|
-
the signature. In contrast, when we use ’…’ it means that
|
444
|
-
the corresponding block is simply instantiated in the current dialect.
|
445
|
-
Implicit dialect modulation is in fact natural: if a block expects an uri
|
446
|
-
for example, the easiest way is to give it exactly:
|
447
|
-
<tt><<{a/file/to/include.txt}</tt>. But you can even compute it using
|
448
|
-
<em>wlang</em>, as illustrated by the example below. In complex situations
|
449
|
-
you will probably be happy to use a dialect that helps you doing so (think
|
450
|
-
at all blocks that expect an expression in the hosting language, for
|
451
|
-
example)!
|
452
|
-
</p>
|
453
|
-
<pre>
|
454
|
-
# Concatenates all files of the 'files' array variable
|
455
|
-
*{files as f}{<<{+{f}}}
|
456
|
-
</pre>
|
95
|
+
<div id="about" style="display: none;">
|
96
|
+
<div class="header">
|
97
|
+
<h2>About</h2>
|
98
|
+
|
99
|
+
<div class="clear"></div>
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<p>
|
103
|
+
WLang is a a reusable and extensible <em>code generator</em>, also known as
|
104
|
+
a <em>templating engine</em>. Motivation for it can be found at <a
|
105
|
+
href="http://www.revision-zero.org/wlang">www.revision-zero.org/wlang</a>.
|
106
|
+
The current file is the reference of the tool.
|
107
|
+
</p>
|
108
|
+
<h3>Topics</h3>
|
109
|
+
<dl>
|
110
|
+
<dt>Short overview</dt><dd>Probably the first section to read! Basic usage of <em>wlang</em> is
|
111
|
+
explained here and pointers are given to continue your learning.
|
112
|
+
|
113
|
+
</dd>
|
114
|
+
<dt>Rulesets</dt><dd>Standard rulesets are specified. As most of them are included in standard
|
115
|
+
dialects, looking at standard rulesets is the quickest way to learn all of
|
116
|
+
them at once.
|
117
|
+
|
118
|
+
</dd>
|
119
|
+
<dt>Dialects</dt><dd>Standard dialects are described. This page also provides useful cheatsheets
|
120
|
+
of available tags in standard dialects.
|
121
|
+
|
122
|
+
</dd>
|
123
|
+
<dt>Hosting language</dt><dd>Somewhat more tricky but powerful. The notion of hosting language is
|
124
|
+
explained more deeply. Implementing you own hosting language abstraction
|
125
|
+
(advanced topic) sometimes leads to cleaner and cross-implementation
|
126
|
+
templates.
|
127
|
+
|
128
|
+
</dd>
|
129
|
+
<dt>Glossary</dt><dd><em>wlang</em> comes with a terminology, knowing it will make your reading
|
130
|
+
easier.
|
131
|
+
|
132
|
+
</dd>
|
133
|
+
<dt>Symbols</dt><dd>If you plan to create your own tags, it can be useful to know what is
|
134
|
+
allowed and what is not. This pages covers this topic.
|
135
|
+
|
136
|
+
</dd>
|
137
|
+
</dl>
|
138
|
+
<h3>About this document</h3>
|
139
|
+
<p>
|
140
|
+
This document is a simple .html file without external dependencies
|
141
|
+
(embedded CSS and javascript). As it contains several cheatsheets, you can
|
142
|
+
simply save it on your harddisk without having to be online to browse the
|
143
|
+
documentation. It has been generated using <em>wlang</em> itself using the
|
144
|
+
following command:
|
145
|
+
</p>
|
146
|
+
<pre>
|
147
|
+
wlang specification.wtpl
|
148
|
+
</pre>
|
149
|
+
<p>
|
150
|
+
The file ‘specification.wtpl’ is almost empty and other files
|
151
|
+
next to it are all kept simple and written in the most appropriate format
|
152
|
+
for the task at hand (YAML for structured parts, RDoc for text sections,
|
153
|
+
sometimes YAML embedding short sentences writted in RDoc style, etc.). One
|
154
|
+
way to learn <em>wlang</em> quickly is to download the source distribution
|
155
|
+
and to look how this is made possible ;-)
|
156
|
+
</p>
|
157
|
+
<p>
|
158
|
+
This reference document is under a <a
|
159
|
+
href="http://creativecommons.org/licenses/by/2.0/be/">Creative Commons
|
160
|
+
Licence 2.0</a> contract. You can use it, redistribute it and modify it
|
161
|
+
providing that you keep a reference to the original licensor (namely, the
|
162
|
+
‘University of Louvain’ or ‘Bernard and Louis
|
163
|
+
Lambeau’).
|
164
|
+
</p>
|
165
|
+
<p>
|
166
|
+
Enjoy <em>wlang</em> !
|
167
|
+
</p>
|
168
|
+
<h3>Distribution</h3>
|
169
|
+
<ul>
|
170
|
+
<li>The reference implementation of <em>wlang</em>, implemented in Ruby, is
|
171
|
+
freely available as a ‘wlang’ gem (under MIT licence). <br/>
|
172
|
+
Use <tt>'gem install wlang'</tt> to install it. For repository and bug
|
173
|
+
tracker visit us on <a href="http://github.com/blambeau/wlang">github</a>
|
174
|
+
|
175
|
+
</li>
|
176
|
+
<li>We don’t have another implementation up to now. If you plan to start
|
177
|
+
one in another language, let us know!
|
178
|
+
|
179
|
+
</li>
|
180
|
+
</ul>
|
181
|
+
<h3>Authors</h3>
|
182
|
+
<p>
|
183
|
+
<em>wlang</em> has been initially designed by Bernard and Louis Lambeau
|
184
|
+
during the implementation of w@w, yet another web framework (proof of
|
185
|
+
concept). They are also maintainers of the reference implementation.
|
186
|
+
</p>
|
187
|
+
<h3>Credits</h3>
|
188
|
+
<p>
|
189
|
+
This work is supported by the <a
|
190
|
+
href="http://www.uclouvain.be/en-ingi.html">department of computer
|
191
|
+
science</a> of the <a
|
192
|
+
href="http://www.uclouvain.be/en-index.html">University of Louvain</a>
|
193
|
+
(EPL/INGI, Universite Catholique de Louvain, UCL, Louvain-la-Neuve,
|
194
|
+
Belgium).
|
195
|
+
</p>
|
196
|
+
<p>
|
197
|
+
This work was also partially supported by the Regional Government of
|
198
|
+
Wallonia (ReQuest project, RW Conv. 315592 and GISELE project, RW Conv.
|
199
|
+
616425) and the MoVES project (PAI program of the Belgian government).
|
200
|
+
</p>
|
201
|
+
|
202
|
+
|
203
|
+
</div>
|
457
204
|
|
205
|
+
<div id="overview" style="display: none;">
|
206
|
+
<div class="header">
|
207
|
+
<h2>Overview</h2>
|
208
|
+
|
209
|
+
<div class="clear"></div>
|
210
|
+
</div>
|
211
|
+
|
212
|
+
<h3>What is <em>wlang</em> designed for?</h3>
|
213
|
+
<p>
|
214
|
+
<em>wlang</em> helps you <b>generating code</b>, in a broad sense. It was
|
215
|
+
originally the templating engine of w@w, a proof-of-concept web framework.
|
216
|
+
While more powerful than the original version, the <b>templating engine</b>
|
217
|
+
ability of <em>wlang</em> has been kept unchanged. For this reason,
|
218
|
+
generating html code with <em>wlang</em> is probably a bit more mature than
|
219
|
+
generating ruby, java or sql code, to take some examples of what
|
220
|
+
<em>wlang</em> can do. It is the author opinion that <em>wlang</em> will
|
221
|
+
also become mature quiclky for these tasks because of its foundations:
|
222
|
+
<b>its engine is generic</b> (in a sense, <em>wlang</em> does not really
|
223
|
+
care about what it generates) but is <b>fully and easily configurable</b>.
|
224
|
+
Generation of html files is mature because <em>wlang</em> has been used a
|
225
|
+
lot for such a job; thus its authors have acquired experience of what is
|
226
|
+
useful when generating simple as well as complex html files. This
|
227
|
+
experience led us to a mature configuration of the <em>wlang</em> engine
|
228
|
+
for generating html files, as the following paragraph illustrates (for
|
229
|
+
people interested in generating code in other languages than html,
|
230
|
+
don’t stop your reading here: the paragraph immediately following
|
231
|
+
contains information for you!)
|
232
|
+
</p>
|
233
|
+
<p>
|
234
|
+
Consider this file for example, which is completely self-contained. It
|
235
|
+
consists of several parts, some of them being structured - the tables for
|
236
|
+
example - while others are not. It also embeds a complete CSS stylesheet
|
237
|
+
and some javascript functions. We have not written this file manually, nor
|
238
|
+
do we maintain it this way. In fact, this reference document is entirely
|
239
|
+
generated by <em>wlang</em> itself from separated parts written mainly in
|
240
|
+
yaml and rdoc files. Also, the cheatsheets given later contains a lot of
|
241
|
+
examples. To ensure that all of them are correct, we simply ask
|
242
|
+
<em>wlang</em> to compute them during generation (technically, we say that
|
243
|
+
<b><em>wlang</em> naturally allows metaprogramming</b>). Lastly, if
|
244
|
+
<em>wlang</em> can be used inside a web framework, it can also be used as a
|
245
|
+
standalone (commandline) tool for generating single files like this one or
|
246
|
+
multiple files, even if all of them are of different nature.
|
247
|
+
</p>
|
248
|
+
<p>
|
249
|
+
<b>Maybe you are looking for a code generator for another language than
|
250
|
+
html</b> (which one does not really care, unless really specific; we call
|
251
|
+
it the <em>target language</em>)? Don’t be affraid by our previous
|
252
|
+
words about <em>wlang</em>’s maturity: even in such a case,
|
253
|
+
<em>wlang</em> is your friend. Start with an existing dialect (see later
|
254
|
+
about dialects), which will provide basic utilities for starting and try to
|
255
|
+
identify common patterns when you use them. Then simply create special
|
256
|
+
shortcuts that are more friendly to use than combining several existing
|
257
|
+
utils … you are on the way of creating your own mature and reusable
|
258
|
+
dialect for that target language. In this case, don’t forget to share
|
259
|
+
it …
|
260
|
+
</p>
|
261
|
+
<h3>Template and instantiation</h3>
|
262
|
+
<p>
|
263
|
+
The <em>wlang</em> grammar used to write a <em>template</em> is generic and
|
264
|
+
simple: every character stands for itself (meaning that it is reproduced
|
265
|
+
exactly when the template is instantiated) except <em>tags</em> (and their
|
266
|
+
associated <em>blocks</em>, enclosed between ’{’ and
|
267
|
+
’}’) that are replaced by what is called the <em>replacement
|
268
|
+
value</em>. Consider the following example:
|
269
|
+
</p>
|
270
|
+
<pre>
|
271
|
+
<html>
|
272
|
+
<head>
|
273
|
+
<title>${title}</title>
|
274
|
+
</head>
|
275
|
+
<body>
|
276
|
+
<h1>Hello *{authors as who}{${who}}{, } !</h1>
|
277
|
+
</body>
|
278
|
+
</html>
|
279
|
+
</pre>
|
280
|
+
<p>
|
281
|
+
Assume that we have some instantitation data through the following hash (or
|
282
|
+
something similar, like a YAML file):
|
283
|
+
</p>
|
284
|
+
<pre>
|
285
|
+
{"title" => "Short overview of wlang", "authors" => ["blambeau", "llambeau", "ancailliau"]}
|
286
|
+
</pre>
|
287
|
+
<p>
|
288
|
+
When instantiated this template will produce exactly the same html file
|
289
|
+
except for special tags <tt>${title}</tt> and <tt>*{whos as who}{${who}}{,
|
290
|
+
}</tt> that will be replaced by <tt>'Short overview of wlang'</tt> and
|
291
|
+
<tt>'blambeau, llambeau, ancailliau'</tt>, respectively. A lot of tags is
|
292
|
+
available, each of them being designed for a specific task: inserting the
|
293
|
+
value of a variable, iterating over collections, including another file,
|
294
|
+
dynamically loading instantiation data, etc. All of these things are
|
295
|
+
commonly proposed by templating engines and <em>wlang</em> is one of them
|
296
|
+
… However, <em>wlang</em> is a bit different as will quickly appear.
|
297
|
+
</p>
|
298
|
+
<p>
|
299
|
+
Indeed (and maybe surprisingly) <em>wlang</em> can also behave really
|
300
|
+
differently on the same template: replacing <tt>${title}</tt> but not
|
301
|
+
<tt>*{...}</tt> or the converse, or not replacing anything, or replacing
|
302
|
+
both tags but not <tt>${who}</tt>, etc. All of this is possible in
|
303
|
+
<em>wlang</em>. The magic relies under the notion of <em>dialect</em>,
|
304
|
+
which you need to understand.
|
305
|
+
</p>
|
306
|
+
<h3>Dialects and Rulesets</h3>
|
307
|
+
<p>
|
308
|
+
The notion of dialect drives the recognition of tags as well as their
|
309
|
+
replacement during instantiation. Dialects are what makes <em>wlang</em>
|
310
|
+
really powerful: if instantiated as being written in the
|
311
|
+
<tt>wlang/xhtml</tt> dialect, the template above will give the result
|
312
|
+
mentionned previously. In contrast, if written in <tt>wlang/dummy</tt> the
|
313
|
+
template will be reproduced whitout any change (no tag replacement at all).
|
314
|
+
This behavior is not hardcoded; it results from the definition of wlang
|
315
|
+
(standard) dialects: <tt>wlang/xhtml</tt> define special meanings for
|
316
|
+
<tt>${...}</tt> and <tt>*{...}{...}{...}</tt> while <tt>wlang/dummy</tt>
|
317
|
+
does not.
|
318
|
+
</p>
|
319
|
+
<p>
|
320
|
+
The replacement of a given <em>tag</em> during instantiation is computed by
|
321
|
+
what we call the <em>rule</em> attached to the tag (keeping rules and tags
|
322
|
+
as different concepts leads to another feature of <em>wlang</em>: you can
|
323
|
+
reuse rule implementations and attach them to other tags than those
|
324
|
+
proposed). A dialect comes with a set of (tag, rule) pairs that determine
|
325
|
+
its replacement behavior. Such a set is called a <em>ruleset</em>; for
|
326
|
+
easier reuse, standard rulesets are already implemented. A dialect is a
|
327
|
+
packaging of standard rulesets (and maybe implements specific tag/rule
|
328
|
+
pairs) designed for generating code in a given target language.
|
329
|
+
</p>
|
330
|
+
<p>
|
331
|
+
A complete <em>wlang</em> implementation already provides standard dialects
|
332
|
+
for common tasks: creating html pages, building SQL queries, generating
|
333
|
+
code in Ruby or in another language, etc. Each dialect comes with special
|
334
|
+
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 for
|
336
|
+
generating an html page where, in contrast, a tag for encoding entities is
|
337
|
+
probably welcome). Such an implementation also allows you to extend
|
338
|
+
standard dialects and to create your own dialect by implementing specific
|
339
|
+
tags and rules or by reusing existing ones. Lastlty, the dialect in used
|
340
|
+
during instantiation can be changed dynamically (<em>explicitly</em>, by
|
341
|
+
using the <tt>%{dialect/qualified/name}{...}</tt> standard tag and
|
342
|
+
<em>implicitly</em>, when rules parse their blocks).
|
343
|
+
</p>
|
344
|
+
<p>
|
345
|
+
To learn more about standard dialects and reusable rules, read the
|
346
|
+
‘Dialects’ and ‘Rulesets’ pages of this
|
347
|
+
documentation.
|
348
|
+
</p>
|
349
|
+
<h3>Grammar</h3>
|
350
|
+
<p>
|
351
|
+
The (abstract) <em>wlang</em> grammar rules what forms a valid template. At
|
352
|
+
first glance, this grammar does not depend on the dialect that is used for
|
353
|
+
instantiation. It is simple, but comes with some constraints that are
|
354
|
+
explained below:
|
355
|
+
</p>
|
356
|
+
<ul>
|
357
|
+
<li>block delimiters are ’{’ and ’}’ by default;
|
358
|
+
<em>wlang</em> can be configured to use ’(’ and ’)’
|
359
|
+
or ’[’ and ’]’ instead. However, block
|
360
|
+
<b>delimiters are template-specific</b>: only one kind of delimiters can be
|
361
|
+
used inside the same template.
|
362
|
+
|
363
|
+
</li>
|
364
|
+
<li>block delimiters <b>must always be paired</b>, even when not used for
|
365
|
+
delimiting blocks. If an opening or closing delimiter is not paired, it
|
366
|
+
must be escaped with a backslash, which will not be reproduced. If you want
|
367
|
+
a backslash to appear before a block delimiter in the instantiation result,
|
368
|
+
use a double backslash.
|
369
|
+
|
370
|
+
</li>
|
371
|
+
<li>if a given tag has a special meaning in the current dialect and you
|
372
|
+
don’t want it to be replaced by <em>wlang</em> you can escape it with
|
373
|
+
a backslash as well (the backslash will not be reproduced).
|
374
|
+
|
375
|
+
</li>
|
376
|
+
<li>some tags (precisely: some rules associated with tags) require multiple
|
377
|
+
blocks (like <tt>*{...}{...}{...}</tt> in <tt>wlang/xhtml</tt> for example,
|
378
|
+
with the third block bein optional). In such a case no character is allowed
|
379
|
+
between the end of a block ’}’ and the start of the next one
|
380
|
+
’{’, not even spaces or a carriage return. In other words,
|
381
|
+
multiple blocks (that must be interpreted as such) must touch each others
|
382
|
+
using ’}{’ precisely, as ilustrated below. If a non-optional
|
383
|
+
block is missing a parse error is raised by the <em>wlang</em>
|
384
|
+
implementation.
|
385
|
+
|
386
|
+
<pre>
|
387
|
+
*{authors as who}{${who}}{, } -> blambeau, llambeau, ancailliau
|
388
|
+
*{authors as who}{${who}} {, } -> blambeaullambeauancailliau {, }
|
389
|
+
*{authors as who} {${who}}{, } -> parse error 1:18, missing block 2 in *{...}{...}
|
390
|
+
</pre>
|
391
|
+
</li>
|
392
|
+
</ul>
|
393
|
+
<p>
|
394
|
+
In addition to these constraints, dialects and the hosting language may
|
395
|
+
impose restrictions on what can be put inside specific blocks of tags/rules
|
396
|
+
(for example, ‘authors as who’ is valid as first tag of
|
397
|
+
<tt>*{...}{...}</tt> but not every string is, of course). These constraints
|
398
|
+
are not specific to the wlang grammar <em>per se</em> and are explained in
|
399
|
+
the ‘Rulesets’, ‘Dialects’ and ‘Hosting
|
400
|
+
language’ pages of this document.
|
401
|
+
</p>
|
402
|
+
|
403
|
+
|
404
|
+
</div>
|
458
405
|
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
406
|
+
<div id="rulesets" style="display: none;">
|
407
|
+
<div class="header">
|
408
|
+
<h2>Rulesets</h2>
|
409
|
+
|
410
|
+
<ul class="links">
|
411
|
+
<li><a href="#Buffering">Buffering</a></li><li><a href="#Context">Context</a></li><li><a href="#Imperative">Imperative</a></li><li><a href="#Encoding">Encoding</a></li><li><a href="#Basic">Basic</a></li>
|
412
|
+
</ul>
|
413
|
+
|
414
|
+
<div class="clear"></div>
|
415
|
+
</div>
|
416
|
+
|
417
|
+
<p>
|
418
|
+
Standard ruleset are designed to be reusable: including them in your own
|
419
|
+
dialect is made easy by a typical <em>wlang</em> implementation. Some of
|
420
|
+
them are also included by standard dialects.
|
421
|
+
</p>
|
422
|
+
<h3>How to read this cheatsheet?</h3>
|
423
|
+
<p>
|
424
|
+
First of all, focus on the examples; they are written to let you learn
|
425
|
+
<em>wlang</em> quickly and deeply. Some of them are a bit difficult to
|
426
|
+
understand but they are representative of <em>wlang</em> powerfulness
|
427
|
+
(don’t be affraid: in practice, some constructions are never used).
|
428
|
+
Don’t forget that the <tt>wlang/dummy</tt> dialect does not recognize
|
429
|
+
any tag. We also assume instantiation data to be the following hash:
|
430
|
+
</p>
|
431
|
+
<pre>
|
432
|
+
{"name" => "O'Neil",
|
433
|
+
"author" => "blambeau"
|
434
|
+
"authors" => ["blambeau", "llambeau", "ancailliau"]}
|
435
|
+
</pre>
|
436
|
+
<p>
|
437
|
+
Moreover, the dialect column in the examples is important; <em>wlang</em>
|
438
|
+
behaves differently in different dialects. When the dialect does not care,
|
439
|
+
we use <tt>wlang/*</tt> which means ‘in any dialect that includes
|
440
|
+
this ruleset’.
|
441
|
+
</p>
|
442
|
+
<p>
|
443
|
+
Next, certain rule definitions are given as shortcuts for longer
|
444
|
+
expressions, involving other tags. This is somewhat representative of
|
445
|
+
<em>wlang</em> usage, even if these rules are not actually implemented this
|
446
|
+
way (mainly for efficiency concerns). Once again, understanding shortcuts
|
447
|
+
will help you mastering wlang! In definitions (textual as well as
|
448
|
+
shortcuts), we use #1, #2, and #3 to refer to the content of the blocks.
|
449
|
+
Those identifiers are not real <em>wlang</em> constructs, but are only used
|
450
|
+
here for easier explanations (for those who know this kind of vocabulary:
|
451
|
+
they are part of the meta-language, not the language <em>per se</em>).
|
452
|
+
</p>
|
453
|
+
<p>
|
454
|
+
Lastly, dialect names that appear in rule signatures are to be interpreted
|
455
|
+
as an implicit dialect modulation: the corresponding block (often the first
|
456
|
+
one) is not instantiated in the current dialect but in the one specified by
|
457
|
+
the signature. In contrast, when we use ’…’ it means that
|
458
|
+
the corresponding block is simply instantiated in the current dialect.
|
459
|
+
Implicit dialect modulation is in fact natural: if a block expects an uri
|
460
|
+
for example, the easiest way is to give it exactly:
|
461
|
+
<tt><<{a/file/to/include.txt}</tt>. But you can even compute it using
|
462
|
+
<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 doing so (think
|
464
|
+
at all blocks that expect an expression in the hosting language, for
|
465
|
+
example)!
|
466
|
+
</p>
|
467
|
+
<pre>
|
468
|
+
# Concatenates all files of the 'files' array variable
|
469
|
+
*{files as f}{<<{+{f}}}
|
470
|
+
</pre>
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
<h3 id="Basic">Basic</h3>
|
475
|
+
<p>
|
476
|
+
The Basic ruleset is commonly installed on any dialect and provides access
|
477
|
+
to <em>wlang</em> foundations inside your template: requesting the hosting
|
478
|
+
language to execute some expression, changing the current dialect and
|
479
|
+
encoding text.
|
480
|
+
</p>
|
481
|
+
|
482
|
+
<table class="ruleset">
|
483
|
+
<tr>
|
484
|
+
<th class="signature">signature</th>
|
485
|
+
<th class="name">name</th>
|
486
|
+
<th class="definition">definition</th>
|
487
|
+
</tr>
|
466
488
|
|
467
|
-
<table class="ruleset">
|
468
|
-
<tr>
|
469
|
-
<th class="signature">signature</th>
|
470
|
-
<th class="name">name</th>
|
471
|
-
<th class="definition">definition</th>
|
472
|
-
</tr>
|
473
489
|
<tr>
|
474
490
|
<td class="signature"><tt>!{wlang/hosted}</tt></td>
|
475
491
|
<td class="name">execution</td>
|
476
492
|
<td class="definition">Instantiates #1, looking for an expression of the hosting language.
|
477
|
-
|
478
|
-
|
479
|
-
|
493
|
+
Evaluates it, looking for any object. Converts it to a string (using to_s
|
494
|
+
for example if Ruby is the hosting language) and returns the result as
|
495
|
+
replacement value.</td>
|
480
496
|
</tr>
|
497
|
+
|
481
498
|
<tr>
|
482
499
|
<td class="signature"><tt>%{wlang/active-string}{...}</tt></td>
|
483
500
|
<td class="name">modulation</td>
|
484
501
|
<td class="definition">Instantiates #1, looking for a dialect qualified name. Instantiates #2
|
485
|
-
|
486
|
-
|
502
|
+
according to the rules defined by that dialect and returns the #2’s
|
503
|
+
instantiation as replacement value.</td>
|
487
504
|
</tr>
|
505
|
+
|
488
506
|
<tr>
|
489
507
|
<td class="signature"><tt>^{wlang/active-string}{...}</tt></td>
|
490
508
|
<td class="name">encoding</td>
|
491
509
|
<td class="definition">Instantiates #1, looking for an encoder qualified name. Instantiates #2 in
|
492
|
-
|
493
|
-
|
510
|
+
the current dialect. Encode #2’s instantiation using encoder found in
|
511
|
+
(#1) and returns encoding as replacement value.</td>
|
494
512
|
</tr>
|
513
|
+
|
495
514
|
<tr>
|
496
515
|
<td class="signature"><tt>%!{wlang/active-string <using>? <with>?}{...}</tt></td>
|
497
516
|
<td class="name">recursive-application</td>
|
498
517
|
<td class="definition">Instantiates #1, looking for a dialect qualified name. Instantiates #2 in
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
518
|
+
the current dialect. Instantiates #2’s instantiation in the dialect
|
519
|
+
found in #1, using context installed by ‘using …’ and
|
520
|
+
‘with …’. Returns this instantiation as replacement value
|
521
|
+
(this really advanced rule allows metaprogramming).</td>
|
503
522
|
</tr>
|
523
|
+
|
504
524
|
<tr>
|
505
525
|
<td class="signature"><tt>${wlang/hosted}</tt></td>
|
506
526
|
<td class="name">injection</td>
|
507
527
|
<td class="definition">Same semantics as execution (intended to be overrided).</td>
|
508
528
|
</tr>
|
529
|
+
|
509
530
|
<tr>
|
510
531
|
<td class="signature"><tt>+{wlang/hosted}</tt></td>
|
511
532
|
<td class="name">inclusion</td>
|
512
533
|
<td class="definition">Same semantics as execution (intended to be overrided).</td>
|
513
534
|
</tr>
|
514
535
|
|
515
|
-
|
516
|
-
|
536
|
+
</table>
|
537
|
+
|
538
|
+
|
517
539
|
<br/>
|
518
540
|
<h4>Examples:</h4>
|
519
541
|
<table class="examples">
|
@@ -522,113 +544,159 @@
|
|
522
544
|
<th>wlang expression</th>
|
523
545
|
<th>replacement value</th>
|
524
546
|
</tr>
|
525
|
-
<tr>
|
526
|
-
<td class="dialect">
|
527
|
-
<tt>wlang/active-string</tt>
|
528
|
-
</td>
|
529
|
-
<td class="expression">
|
530
|
-
<tt>Hello !{name}</tt>
|
531
|
-
</td>
|
532
|
-
<td class="replacement">
|
533
|
-
<tt>Hello O'Neil</tt>
|
534
547
|
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
<
|
540
|
-
|
541
|
-
|
542
|
-
<
|
543
|
-
|
544
|
-
|
545
|
-
|
548
|
+
<tr>
|
549
|
+
<td class="dialect">
|
550
|
+
<tt>wlang/active-string</tt>
|
551
|
+
</td>
|
552
|
+
<td class="expression">
|
553
|
+
<tt>Hello !{name}</tt>
|
554
|
+
</td>
|
555
|
+
<td class="replacement">
|
556
|
+
|
557
|
+
<tt>Hello O'Neil</tt>
|
558
|
+
|
559
|
+
</td>
|
560
|
+
</tr>
|
546
561
|
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
<
|
552
|
-
|
553
|
-
|
554
|
-
<
|
555
|
-
|
556
|
-
|
557
|
-
|
562
|
+
<tr>
|
563
|
+
<td class="dialect">
|
564
|
+
<tt>wlang/active-string</tt>
|
565
|
+
</td>
|
566
|
+
<td class="expression">
|
567
|
+
<tt>Hello %{wlang/dummy}{!{name}}</tt>
|
568
|
+
</td>
|
569
|
+
<td class="replacement">
|
570
|
+
|
571
|
+
<tt>Hello !{name}</tt>
|
572
|
+
|
573
|
+
</td>
|
574
|
+
</tr>
|
558
575
|
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
<
|
564
|
-
|
565
|
-
|
566
|
-
<
|
567
|
-
|
568
|
-
|
569
|
-
|
576
|
+
<tr>
|
577
|
+
<td class="dialect">
|
578
|
+
<tt>wlang/dummy</tt>
|
579
|
+
</td>
|
580
|
+
<td class="expression">
|
581
|
+
<tt>Hello %{wlang/dummy}{!{name}}</tt>
|
582
|
+
</td>
|
583
|
+
<td class="replacement">
|
584
|
+
|
585
|
+
<tt>Hello %{wlang/dummy}{!{name}}</tt>
|
586
|
+
|
587
|
+
</td>
|
588
|
+
</tr>
|
589
|
+
|
590
|
+
<tr>
|
591
|
+
<td class="dialect">
|
592
|
+
<tt>wlang/active-string</tt>
|
593
|
+
</td>
|
594
|
+
<td class="expression">
|
595
|
+
<tt>Hello ^{plain-text/upcase}{${name}}</tt>
|
596
|
+
</td>
|
597
|
+
<td class="replacement">
|
598
|
+
|
599
|
+
<tt>Hello O'NEIL</tt>
|
600
|
+
|
601
|
+
</td>
|
602
|
+
</tr>
|
603
|
+
|
604
|
+
<tr>
|
605
|
+
<td class="dialect">
|
606
|
+
<tt>wlang/ruby</tt>
|
607
|
+
</td>
|
608
|
+
<td class="expression">
|
609
|
+
<tt>puts +{name}</tt>
|
610
|
+
</td>
|
611
|
+
<td class="replacement">
|
612
|
+
|
613
|
+
<tt>puts "O'Neil"</tt>
|
614
|
+
|
615
|
+
</td>
|
616
|
+
</tr>
|
617
|
+
|
618
|
+
<tr>
|
619
|
+
<td class="dialect">
|
620
|
+
<tt>wlang/ruby</tt>
|
621
|
+
</td>
|
622
|
+
<td class="expression">
|
623
|
+
<tt>puts +{authors}</tt>
|
624
|
+
</td>
|
625
|
+
<td class="replacement">
|
626
|
+
|
627
|
+
<tt>puts ["blambeau", "llambeau", "ancailliau"]</tt>
|
628
|
+
|
629
|
+
</td>
|
630
|
+
</tr>
|
570
631
|
|
571
|
-
</td>
|
572
|
-
</tr>
|
573
|
-
|
574
632
|
</table>
|
575
633
|
<div style="clear: both;"></div>
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
634
|
+
|
635
|
+
|
636
|
+
<h3 id="Encoding">Encoding</h3>
|
637
|
+
<p>
|
638
|
+
Almost all languages require escaping/encoding in specific situations:
|
639
|
+
quoted string literals always come with an escaping mechanism
|
640
|
+
(unfortunately different from one language to another), html requires
|
641
|
+
entities-encoding, etc. The Encoding ruleset proposes shortcut tags for
|
642
|
+
encoding. Note that these shortcuts are written in such a way that they
|
643
|
+
don’t depend on the effective dialect. <em>wlang</em> hides language
|
644
|
+
and vendors differences!
|
645
|
+
</p>
|
646
|
+
|
647
|
+
<table class="ruleset">
|
648
|
+
<tr>
|
649
|
+
<th class="signature">signature</th>
|
650
|
+
<th class="name">name</th>
|
651
|
+
<th class="definition">definition</th>
|
652
|
+
</tr>
|
586
653
|
|
587
|
-
<table class="ruleset">
|
588
|
-
<tr>
|
589
|
-
<th class="signature">signature</th>
|
590
|
-
<th class="name">name</th>
|
591
|
-
<th class="definition">definition</th>
|
592
|
-
</tr>
|
593
654
|
<tr>
|
594
655
|
<td class="signature"><tt>&{...}</tt></td>
|
595
656
|
<td class="name">main-encoding</td>
|
596
657
|
<td class="definition"><tt>^{+{@parser.current_dialect}/main-encoding}{#1}</tt></td>
|
597
658
|
</tr>
|
659
|
+
|
598
660
|
<tr>
|
599
661
|
<td class="signature"><tt>&;{...}</tt></td>
|
600
662
|
<td class="name">entities-encoding</td>
|
601
663
|
<td class="definition"><tt>^{+{@parser.current_dialect}/entities-encoding}{#1}</tt></td>
|
602
664
|
</tr>
|
665
|
+
|
603
666
|
<tr>
|
604
667
|
<td class="signature"><tt>&'{...}</tt></td>
|
605
668
|
<td class="name">single-quoting</td>
|
606
669
|
<td class="definition"><tt>^{+{@parser.current_dialect}/single-quoting}{#1}</tt></td>
|
607
670
|
</tr>
|
671
|
+
|
608
672
|
<tr>
|
609
673
|
<td class="signature"><tt>&"{...}</tt></td>
|
610
674
|
<td class="name">double-quoting</td>
|
611
675
|
<td class="definition"><tt>^{+{@parser.current_dialect}/double-quoting}{#1}</tt></td>
|
612
676
|
</tr>
|
677
|
+
|
613
678
|
<tr>
|
614
679
|
<td class="signature"><tt>${wlang/hosted}</tt></td>
|
615
680
|
<td class="name">injection</td>
|
616
681
|
<td class="definition"><tt>&{+{#1}}</tt></td>
|
617
682
|
</tr>
|
683
|
+
|
618
684
|
<tr>
|
619
685
|
<td class="signature"><tt>'{wlang/hosted}</tt></td>
|
620
686
|
<td class="name">single-quoted</td>
|
621
687
|
<td class="definition"><tt>'&'{+{#1}}</tt> (first single quote is kept in the result)</td>
|
622
688
|
</tr>
|
689
|
+
|
623
690
|
<tr>
|
624
691
|
<td class="signature"><tt>"{wlang/hosted}</tt></td>
|
625
692
|
<td class="name">double-quoted</td>
|
626
693
|
<td class="definition"><tt>"&"{+{#1}}</tt> (first double quote is kept in the
|
627
|
-
|
694
|
+
result)</td>
|
628
695
|
</tr>
|
629
696
|
|
630
|
-
|
631
|
-
|
697
|
+
</table>
|
698
|
+
|
699
|
+
|
632
700
|
<br/>
|
633
701
|
<h4>Examples:</h4>
|
634
702
|
<table class="examples">
|
@@ -637,137 +705,158 @@
|
|
637
705
|
<th>wlang expression</th>
|
638
706
|
<th>replacement value</th>
|
639
707
|
</tr>
|
640
|
-
<tr>
|
641
|
-
<td class="dialect">
|
642
|
-
<tt>wlang/xhtml</tt>
|
643
|
-
</td>
|
644
|
-
<td class="expression">
|
645
|
-
<tt>Hello &{name}</tt>
|
646
|
-
</td>
|
647
|
-
<td class="replacement">
|
648
|
-
<tt>Hello name</tt>
|
649
708
|
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
<
|
655
|
-
|
656
|
-
|
657
|
-
<
|
658
|
-
|
659
|
-
|
660
|
-
|
709
|
+
<tr>
|
710
|
+
<td class="dialect">
|
711
|
+
<tt>wlang/xhtml</tt>
|
712
|
+
</td>
|
713
|
+
<td class="expression">
|
714
|
+
<tt>Hello &{name}</tt>
|
715
|
+
</td>
|
716
|
+
<td class="replacement">
|
717
|
+
|
718
|
+
<tt>Hello name</tt>
|
719
|
+
|
720
|
+
</td>
|
721
|
+
</tr>
|
661
722
|
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
<
|
667
|
-
|
668
|
-
|
669
|
-
<
|
670
|
-
|
671
|
-
|
672
|
-
|
723
|
+
<tr>
|
724
|
+
<td class="dialect">
|
725
|
+
<tt>wlang/xhtml</tt>
|
726
|
+
</td>
|
727
|
+
<td class="expression">
|
728
|
+
<tt>Hello &{<script>}</tt>
|
729
|
+
</td>
|
730
|
+
<td class="replacement">
|
731
|
+
|
732
|
+
<tt>Hello <script></tt>
|
733
|
+
|
734
|
+
</td>
|
735
|
+
</tr>
|
673
736
|
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
<
|
679
|
-
|
680
|
-
|
681
|
-
<
|
682
|
-
|
683
|
-
|
684
|
-
|
737
|
+
<tr>
|
738
|
+
<td class="dialect">
|
739
|
+
<tt>wlang/xhtml</tt>
|
740
|
+
</td>
|
741
|
+
<td class="expression">
|
742
|
+
<tt>Hello &;{<script>}</tt>
|
743
|
+
</td>
|
744
|
+
<td class="replacement">
|
745
|
+
|
746
|
+
<tt>Hello <script></tt>
|
747
|
+
|
748
|
+
</td>
|
749
|
+
</tr>
|
685
750
|
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
<
|
691
|
-
|
692
|
-
|
693
|
-
<
|
694
|
-
|
695
|
-
|
696
|
-
|
751
|
+
<tr>
|
752
|
+
<td class="dialect">
|
753
|
+
<tt>wlang/ruby</tt>
|
754
|
+
</td>
|
755
|
+
<td class="expression">
|
756
|
+
<tt>puts 'Hello &'{name}'</tt>
|
757
|
+
</td>
|
758
|
+
<td class="replacement">
|
759
|
+
|
760
|
+
<tt>puts 'Hello name'</tt>
|
761
|
+
|
762
|
+
</td>
|
763
|
+
</tr>
|
697
764
|
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
<
|
703
|
-
|
704
|
-
|
705
|
-
<
|
706
|
-
|
707
|
-
|
708
|
-
|
765
|
+
<tr>
|
766
|
+
<td class="dialect">
|
767
|
+
<tt>wlang/ruby</tt>
|
768
|
+
</td>
|
769
|
+
<td class="expression">
|
770
|
+
<tt>puts 'Hello &'{!{name}}'</tt>
|
771
|
+
</td>
|
772
|
+
<td class="replacement">
|
773
|
+
|
774
|
+
<tt>puts 'Hello O\'Neil'</tt>
|
775
|
+
|
776
|
+
</td>
|
777
|
+
</tr>
|
709
778
|
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
<
|
715
|
-
|
716
|
-
|
717
|
-
<
|
718
|
-
|
719
|
-
|
720
|
-
|
779
|
+
<tr>
|
780
|
+
<td class="dialect">
|
781
|
+
<tt>wlang/ruby</tt>
|
782
|
+
</td>
|
783
|
+
<td class="expression">
|
784
|
+
<tt>puts 'Hello ' << '{name}'</tt>
|
785
|
+
</td>
|
786
|
+
<td class="replacement">
|
787
|
+
|
788
|
+
<tt>puts 'Hello ' << 'O\'Neil'</tt>
|
789
|
+
|
790
|
+
</td>
|
791
|
+
</tr>
|
721
792
|
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
<
|
727
|
-
|
728
|
-
|
729
|
-
<
|
730
|
-
|
731
|
-
|
732
|
-
|
793
|
+
<tr>
|
794
|
+
<td class="dialect">
|
795
|
+
<tt>wlang/sql</tt>
|
796
|
+
</td>
|
797
|
+
<td class="expression">
|
798
|
+
<tt>... WHERE name='{name}'</tt>
|
799
|
+
</td>
|
800
|
+
<td class="replacement">
|
801
|
+
|
802
|
+
<tt>... WHERE name='O\'Neil'</tt>
|
803
|
+
|
804
|
+
</td>
|
805
|
+
</tr>
|
806
|
+
|
807
|
+
<tr>
|
808
|
+
<td class="dialect">
|
809
|
+
<tt>wlang/sql/sybase</tt>
|
810
|
+
</td>
|
811
|
+
<td class="expression">
|
812
|
+
<tt>... WHERE name='{name}'</tt>
|
813
|
+
</td>
|
814
|
+
<td class="replacement">
|
815
|
+
|
816
|
+
<tt>... WHERE name='O''Neil'</tt>
|
817
|
+
|
818
|
+
</td>
|
819
|
+
</tr>
|
733
820
|
|
734
|
-
</td>
|
735
|
-
</tr>
|
736
|
-
|
737
821
|
</table>
|
738
822
|
<div style="clear: both;"></div>
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
823
|
+
|
824
|
+
|
825
|
+
<h3 id="Imperative">Imperative</h3>
|
826
|
+
<p>
|
827
|
+
Instantiating conditionally and iterating collection elements are common
|
828
|
+
code generation tasks. The Imperative dialect provides these features.
|
829
|
+
</p>
|
830
|
+
|
831
|
+
<table class="ruleset">
|
832
|
+
<tr>
|
833
|
+
<th class="signature">signature</th>
|
834
|
+
<th class="name">name</th>
|
835
|
+
<th class="definition">definition</th>
|
836
|
+
</tr>
|
744
837
|
|
745
|
-
<table class="ruleset">
|
746
|
-
<tr>
|
747
|
-
<th class="signature">signature</th>
|
748
|
-
<th class="name">name</th>
|
749
|
-
<th class="definition">definition</th>
|
750
|
-
</tr>
|
751
838
|
<tr>
|
752
839
|
<td class="signature"><tt>?{wlang/hosted}{...}{...}</tt></td>
|
753
840
|
<td class="name">conditional<br/>(third block is optional)</td>
|
754
841
|
<td class="definition">Instantiates #1, looking for an expression in the hosting language.
|
755
|
-
|
756
|
-
|
757
|
-
|
842
|
+
Evaluates it, looking for a boolean value (according to boolean semantics
|
843
|
+
of the hosting language). If true, instantiates #2, otherwise instantiates
|
844
|
+
#3 if present, returning instantiation as replacement value.</td>
|
758
845
|
</tr>
|
846
|
+
|
759
847
|
<tr>
|
760
848
|
<td class="signature"><tt>*{wlang/hosted <as x>?}{...}{...}</tt></td>
|
761
849
|
<td class="name">enumeration<br/>(third block is optional)</td>
|
762
850
|
<td class="definition">Instantiates #1, looking for an expression in the hosting language.
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
851
|
+
Evaluates it, looking for an enumerable. Iterates all its elements,
|
852
|
+
instantiating #2 for each of them (the iterated value is set under name x
|
853
|
+
in the scope). If #3 is present, it is instantiated between elements.
|
854
|
+
Replacement is the concatenation of all these instantiations.</td>
|
767
855
|
</tr>
|
768
856
|
|
769
|
-
|
770
|
-
|
857
|
+
</table>
|
858
|
+
|
859
|
+
|
771
860
|
<br/>
|
772
861
|
<h4>Examples:</h4>
|
773
862
|
<table class="examples">
|
@@ -776,105 +865,120 @@
|
|
776
865
|
<th>wlang expression</th>
|
777
866
|
<th>replacement value</th>
|
778
867
|
</tr>
|
779
|
-
<tr>
|
780
|
-
<td class="dialect">
|
781
|
-
<tt>wlang/*</tt>
|
782
|
-
</td>
|
783
|
-
<td class="expression">
|
784
|
-
<tt>?{true}{then}{else}</tt>
|
785
|
-
</td>
|
786
|
-
<td class="replacement">
|
787
|
-
<tt>then</tt>
|
788
868
|
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
<
|
794
|
-
|
795
|
-
|
796
|
-
<
|
797
|
-
|
798
|
-
|
799
|
-
|
869
|
+
<tr>
|
870
|
+
<td class="dialect">
|
871
|
+
<tt>wlang/*</tt>
|
872
|
+
</td>
|
873
|
+
<td class="expression">
|
874
|
+
<tt>?{true}{then}{else}</tt>
|
875
|
+
</td>
|
876
|
+
<td class="replacement">
|
877
|
+
|
878
|
+
<tt>then</tt>
|
879
|
+
|
880
|
+
</td>
|
881
|
+
</tr>
|
800
882
|
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
<
|
806
|
-
|
807
|
-
|
808
|
-
<
|
809
|
-
|
810
|
-
|
811
|
-
|
883
|
+
<tr>
|
884
|
+
<td class="dialect">
|
885
|
+
<tt>wlang/*</tt>
|
886
|
+
</td>
|
887
|
+
<td class="expression">
|
888
|
+
<tt>?{/th/ =~ "not tat"}{then}{else}</tt>
|
889
|
+
</td>
|
890
|
+
<td class="replacement">
|
891
|
+
|
892
|
+
<tt>else</tt>
|
893
|
+
|
894
|
+
</td>
|
895
|
+
</tr>
|
812
896
|
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
<
|
818
|
-
|
819
|
-
|
820
|
-
<
|
821
|
-
|
822
|
-
|
823
|
-
|
897
|
+
<tr>
|
898
|
+
<td class="dialect">
|
899
|
+
<tt>wlang/*</tt>
|
900
|
+
</td>
|
901
|
+
<td class="expression">
|
902
|
+
<tt>?{authors.include? "blambeau"}{yes}{no}</tt>
|
903
|
+
</td>
|
904
|
+
<td class="replacement">
|
905
|
+
|
906
|
+
<tt>yes</tt>
|
907
|
+
|
908
|
+
</td>
|
909
|
+
</tr>
|
910
|
+
|
911
|
+
<tr>
|
912
|
+
<td class="dialect">
|
913
|
+
<tt>wlang/*</tt>
|
914
|
+
</td>
|
915
|
+
<td class="expression">
|
916
|
+
<tt>[*{authors as a}{"{a}"}{, }]</tt>
|
917
|
+
</td>
|
918
|
+
<td class="replacement">
|
919
|
+
|
920
|
+
<tt>["blambeau", "llambeau", "ancailliau"]</tt>
|
921
|
+
|
922
|
+
</td>
|
923
|
+
</tr>
|
824
924
|
|
825
|
-
</td>
|
826
|
-
</tr>
|
827
|
-
|
828
925
|
</table>
|
829
926
|
<div style="clear: both;"></div>
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
927
|
+
|
928
|
+
|
929
|
+
<h3 id="Context">Context</h3>
|
930
|
+
<p>
|
931
|
+
Complex templates come with specific needs. The ability to manipulate the
|
932
|
+
context and the current scope is provided by the Context ruleset. All are
|
933
|
+
variants of ‘saving previous instantiations’ in scope
|
934
|
+
variables…
|
935
|
+
</p>
|
936
|
+
|
937
|
+
<table class="ruleset">
|
938
|
+
<tr>
|
939
|
+
<th class="signature">signature</th>
|
940
|
+
<th class="name">name</th>
|
941
|
+
<th class="definition">definition</th>
|
942
|
+
</tr>
|
837
943
|
|
838
|
-
<table class="ruleset">
|
839
|
-
<tr>
|
840
|
-
<th class="signature">signature</th>
|
841
|
-
<th class="name">name</th>
|
842
|
-
<th class="definition">definition</th>
|
843
|
-
</tr>
|
844
944
|
<tr>
|
845
945
|
<td class="signature"><tt>={wlang/hosted <as x>}{...}</tt></td>
|
846
946
|
<td class="name">assignment<br/>(second block is optional)</td>
|
847
947
|
<td class="definition">Instantiates #1, looking for an expression in the hosting language.
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
948
|
+
Evaluates it, looking for any object. Without second block, expands the
|
949
|
+
current scope with ‘x’ being bound to evaluation result.
|
950
|
+
Otherwise, branches the current scope for the second block instantiation
|
951
|
+
only and bind ‘x’ the same way (i.e. x will not be available
|
952
|
+
outside the second block). Returns an empty string as replacement value.</td>
|
853
953
|
</tr>
|
954
|
+
|
854
955
|
<tr>
|
855
956
|
<td class="signature"><tt>%={wlang/active-string <as x>}{...}{...}</tt></td>
|
856
957
|
<td class="name">modulo-assignment<br/>(third block is optional)</td>
|
857
958
|
<td class="definition">Instantiates #1, looking for a dialect qualified name. Instantiates #2
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
959
|
+
according to the rules defined by that dialect. Without third block,
|
960
|
+
expands the current scope with ‘x’ being bound to #2’s
|
961
|
+
instantiation. Otherwise, branches the current scope for the third block
|
962
|
+
instantiation only and binds ‘x’ the same way (i.e. x will not
|
963
|
+
be available outside the third block). Returns an empty string as
|
964
|
+
replacement value.</td>
|
864
965
|
</tr>
|
966
|
+
|
865
967
|
<tr>
|
866
968
|
<td class="signature"><tt>#={wlang/active-string}{...}{...}</tt></td>
|
867
969
|
<td class="name">block-assignment<br/>(third block is optional)</td>
|
868
970
|
<td class="definition"><tt>%={+{@parser.current_dialect} as #1}{#2}{#3}</tt></td>
|
869
971
|
</tr>
|
972
|
+
|
870
973
|
<tr>
|
871
974
|
<td class="signature"><tt>^={wlang/active-string <as x>}{...}{...}</tt></td>
|
872
975
|
<td class="name">encoding-assignment<br/>(third block is optional)</td>
|
873
976
|
<td class="definition"><tt>%={+{@parser.current_dialect} as x}{^{#1}{#2}}{#3}</tt></td>
|
874
977
|
</tr>
|
875
978
|
|
876
|
-
|
877
|
-
|
979
|
+
</table>
|
980
|
+
|
981
|
+
|
878
982
|
<br/>
|
879
983
|
<h4>Examples:</h4>
|
880
984
|
<table class="examples">
|
@@ -883,542 +987,674 @@
|
|
883
987
|
<th>wlang expression</th>
|
884
988
|
<th>replacement value</th>
|
885
989
|
</tr>
|
886
|
-
<tr>
|
887
|
-
<td class="dialect">
|
888
|
-
<tt>wlang/*</tt>
|
889
|
-
</td>
|
890
|
-
<td class="expression">
|
891
|
-
<tt>={name as n}{Hello +{n}}</tt>
|
892
|
-
</td>
|
893
|
-
<td class="replacement">
|
894
|
-
<tt>Hello O'Neil</tt>
|
895
990
|
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
<
|
901
|
-
|
902
|
-
|
903
|
-
<
|
904
|
-
|
905
|
-
|
906
|
-
|
991
|
+
<tr>
|
992
|
+
<td class="dialect">
|
993
|
+
<tt>wlang/*</tt>
|
994
|
+
</td>
|
995
|
+
<td class="expression">
|
996
|
+
<tt>={name as n}{Hello !{n}}</tt>
|
997
|
+
</td>
|
998
|
+
<td class="replacement">
|
999
|
+
|
1000
|
+
<tt>Hello O'Neil</tt>
|
1001
|
+
|
1002
|
+
</td>
|
1003
|
+
</tr>
|
907
1004
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
<
|
913
|
-
|
914
|
-
|
915
|
-
<
|
916
|
-
|
917
|
-
|
918
|
-
|
1005
|
+
<tr>
|
1006
|
+
<td class="dialect">
|
1007
|
+
<tt>wlang/*</tt>
|
1008
|
+
</td>
|
1009
|
+
<td class="expression">
|
1010
|
+
<tt>={name as n}Hello !{n}</tt>
|
1011
|
+
</td>
|
1012
|
+
<td class="replacement">
|
1013
|
+
|
1014
|
+
<tt>Hello O'Neil</tt>
|
1015
|
+
|
1016
|
+
</td>
|
1017
|
+
</tr>
|
919
1018
|
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
<
|
925
|
-
|
926
|
-
|
927
|
-
<
|
928
|
-
|
929
|
-
|
930
|
-
|
1019
|
+
<tr>
|
1020
|
+
<td class="dialect">
|
1021
|
+
<tt>wlang/*</tt>
|
1022
|
+
</td>
|
1023
|
+
<td class="expression">
|
1024
|
+
<tt>#={name}{blambeau}{Hello !{name}} and !{name}</tt>
|
1025
|
+
</td>
|
1026
|
+
<td class="replacement">
|
1027
|
+
|
1028
|
+
<tt>Hello blambeau and O'Neil</tt>
|
1029
|
+
|
1030
|
+
</td>
|
1031
|
+
</tr>
|
931
1032
|
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
<
|
937
|
-
|
938
|
-
|
939
|
-
<
|
940
|
-
|
941
|
-
|
942
|
-
|
1033
|
+
<tr>
|
1034
|
+
<td class="dialect">
|
1035
|
+
<tt>wlang/*</tt>
|
1036
|
+
</td>
|
1037
|
+
<td class="expression">
|
1038
|
+
<tt>#={name}{blambeau}Hello !{name} and !{name}</tt>
|
1039
|
+
</td>
|
1040
|
+
<td class="replacement">
|
1041
|
+
|
1042
|
+
<tt>Hello blambeau and blambeau</tt>
|
1043
|
+
|
1044
|
+
</td>
|
1045
|
+
</tr>
|
943
1046
|
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
<
|
949
|
-
|
950
|
-
|
951
|
-
<
|
952
|
-
|
953
|
-
|
954
|
-
|
1047
|
+
<tr>
|
1048
|
+
<td class="dialect">
|
1049
|
+
<tt>wlang/*</tt>
|
1050
|
+
</td>
|
1051
|
+
<td class="expression">
|
1052
|
+
<tt>={author as name}{Hello !{name}} and !{name}</tt>
|
1053
|
+
</td>
|
1054
|
+
<td class="replacement">
|
1055
|
+
|
1056
|
+
<tt>Hello blambeau and O'Neil</tt>
|
1057
|
+
|
1058
|
+
</td>
|
1059
|
+
</tr>
|
955
1060
|
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
<
|
961
|
-
|
962
|
-
|
963
|
-
<
|
964
|
-
|
965
|
-
|
966
|
-
|
1061
|
+
<tr>
|
1062
|
+
<td class="dialect">
|
1063
|
+
<tt>wlang/*</tt>
|
1064
|
+
</td>
|
1065
|
+
<td class="expression">
|
1066
|
+
<tt>={author as name}Hello !{name} and !{name}</tt>
|
1067
|
+
</td>
|
1068
|
+
<td class="replacement">
|
1069
|
+
|
1070
|
+
<tt>Hello blambeau and blambeau</tt>
|
1071
|
+
|
1072
|
+
</td>
|
1073
|
+
</tr>
|
967
1074
|
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
<
|
973
|
-
|
974
|
-
|
975
|
-
<
|
976
|
-
|
977
|
-
|
978
|
-
|
1075
|
+
<tr>
|
1076
|
+
<td class="dialect">
|
1077
|
+
<tt>wlang/*</tt>
|
1078
|
+
</td>
|
1079
|
+
<td class="expression">
|
1080
|
+
<tt>%={wlang/dummy as hello}{Hello !{name}}{!{hello}}</tt>
|
1081
|
+
</td>
|
1082
|
+
<td class="replacement">
|
1083
|
+
|
1084
|
+
<tt>Hello !{name}</tt>
|
1085
|
+
|
1086
|
+
</td>
|
1087
|
+
</tr>
|
979
1088
|
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
<
|
985
|
-
|
986
|
-
|
987
|
-
<
|
988
|
-
|
989
|
-
|
990
|
-
|
1089
|
+
<tr>
|
1090
|
+
<td class="dialect">
|
1091
|
+
<tt>wlang/*</tt>
|
1092
|
+
</td>
|
1093
|
+
<td class="expression">
|
1094
|
+
<tt>^={plain-text/upcase as name}{!{author}}{Hello !{name}} and !{name}</tt>
|
1095
|
+
</td>
|
1096
|
+
<td class="replacement">
|
1097
|
+
|
1098
|
+
<tt>Hello BLAMBEAU and O'Neil</tt>
|
1099
|
+
|
1100
|
+
</td>
|
1101
|
+
</tr>
|
1102
|
+
|
1103
|
+
<tr>
|
1104
|
+
<td class="dialect">
|
1105
|
+
<tt>wlang/*</tt>
|
1106
|
+
</td>
|
1107
|
+
<td class="expression">
|
1108
|
+
<tt>^={plain-text/upcase as name}{!{author}}Hello !{name} and !{name}</tt>
|
1109
|
+
</td>
|
1110
|
+
<td class="replacement">
|
1111
|
+
|
1112
|
+
<tt>Hello BLAMBEAU and BLAMBEAU</tt>
|
1113
|
+
|
1114
|
+
</td>
|
1115
|
+
</tr>
|
991
1116
|
|
992
|
-
</td>
|
993
|
-
</tr>
|
994
|
-
|
995
1117
|
</table>
|
996
1118
|
<div style="clear: both;"></div>
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1119
|
+
|
1120
|
+
|
1121
|
+
<h3 id="Buffering">Buffering</h3>
|
1122
|
+
<p>
|
1123
|
+
The Buffering ruleset is probably one of the more useful. It allows you to
|
1124
|
+
load text and data files, to change the current output buffer (for
|
1125
|
+
generating multiple files for example) and even to start the instantiation
|
1126
|
+
on other templates.
|
1127
|
+
</p>
|
1128
|
+
|
1129
|
+
<table class="ruleset">
|
1130
|
+
<tr>
|
1131
|
+
<th class="signature">signature</th>
|
1132
|
+
<th class="name">name</th>
|
1133
|
+
<th class="definition">definition</th>
|
1134
|
+
</tr>
|
1004
1135
|
|
1005
|
-
<table class="ruleset">
|
1006
|
-
<tr>
|
1007
|
-
<th class="signature">signature</th>
|
1008
|
-
<th class="name">name</th>
|
1009
|
-
<th class="definition">definition</th>
|
1010
|
-
</tr>
|
1011
1136
|
<tr>
|
1012
1137
|
<td class="signature"><tt><<{wlang/uri}</tt></td>
|
1013
1138
|
<td class="name">input</td>
|
1014
1139
|
<td class="definition">Instantiates #1, looking for an uri. Returns the text content of the found
|
1015
|
-
|
1140
|
+
uri (#1) as replacement value.</td>
|
1016
1141
|
</tr>
|
1142
|
+
|
1017
1143
|
<tr>
|
1018
1144
|
<td class="signature"><tt>>>{wlang/uri}{...}</tt></td>
|
1019
1145
|
<td class="name">output</td>
|
1020
1146
|
<td class="definition">Instantiates #1, looking for an uri. Instantiates #2 in the current
|
1021
|
-
|
1022
|
-
|
1147
|
+
dialect, using the file found in #1 as output buffer. Returns an empty
|
1148
|
+
string as replacement value.</td>
|
1023
1149
|
</tr>
|
1150
|
+
|
1024
1151
|
<tr>
|
1025
1152
|
<td class="signature"><tt><<={wlang/uri <as x>}{...}</tt></td>
|
1026
1153
|
<td class="name">data-assignment</td>
|
1027
1154
|
<td class="definition">Instantiates #1, looking for an uri. Loads data provided by this uri, based
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1155
|
+
on the file extension (typically .yml or .rb). Without second block,
|
1156
|
+
expands the current scope with ‘x’ being bound to the data.
|
1157
|
+
Otherwise, branches the current scope for the second block instantiation
|
1158
|
+
only and binds ‘x’ the same way (i.e. x will not be available
|
1159
|
+
outside the second block). Returns an empty string as replacement value.</td>
|
1033
1160
|
</tr>
|
1161
|
+
|
1034
1162
|
<tr>
|
1035
1163
|
<td class="signature"><tt><<+{wlang/uri <using>? <with>?}</tt></td>
|
1036
1164
|
<td class="name">input-inclusion</td>
|
1037
1165
|
<td class="definition">Instantiates #1, looking for an uri. Instantiates the <em>wlang</em>
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1166
|
+
template at this location (the dialect is infered from the file extension)
|
1167
|
+
in a fresh new scope built from the <em>with</em> expression. Returns this
|
1168
|
+
instantiation as replacement value.</td>
|
1041
1169
|
</tr>
|
1042
1170
|
|
1043
|
-
|
1171
|
+
</table>
|
1172
|
+
|
1173
|
+
|
1174
|
+
|
1175
|
+
|
1176
|
+
|
1177
|
+
</div>
|
1044
1178
|
|
1179
|
+
<div id="dialects" style="display: none;">
|
1180
|
+
<div class="header">
|
1181
|
+
<h2>Dialects</h2>
|
1182
|
+
|
1183
|
+
<div class="clear"></div>
|
1184
|
+
</div>
|
1185
|
+
|
1186
|
+
|
1187
|
+
<div class="dialect">
|
1188
|
+
<div style="margin-bottom: 20px">
|
1189
|
+
<h3 style="display: inline">wlang/hosted</h3>
|
1190
|
+
|
1191
|
+
<p style="display: inline">Includes Basic, Encoding, Imperative, Context, Hosted</p>
|
1192
|
+
|
1193
|
+
</div>
|
1194
|
+
|
1195
|
+
|
1196
|
+
</div>
|
1197
|
+
|
1198
|
+
|
1199
|
+
<div class="dialect">
|
1200
|
+
<div style="margin-bottom: 20px">
|
1201
|
+
<h3 style="display: inline">wlang/uri</h3>
|
1045
1202
|
|
1046
|
-
</div>
|
1047
|
-
<div id="dialects" style="display: none;">
|
1048
|
-
<div class="header">
|
1049
|
-
<h2>Dialects</h2>
|
1050
|
-
|
1051
|
-
<div class="clear"></div>
|
1052
|
-
</div>
|
1053
|
-
<div class="dialect">
|
1054
|
-
<div style="margin-bottom: 20px">
|
1055
|
-
<h3 style="display: inline">wlang/uri</h3>
|
1056
1203
|
<p style="display: inline">Includes Basic</p>
|
1057
1204
|
|
1058
|
-
|
1205
|
+
</div>
|
1206
|
+
|
1207
|
+
|
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>
|
1059
1216
|
|
1217
|
+
</div>
|
1218
|
+
|
1219
|
+
|
1220
|
+
</div>
|
1221
|
+
|
1222
|
+
|
1223
|
+
<div class="dialect">
|
1224
|
+
<div style="margin-bottom: 20px">
|
1225
|
+
<h3 style="display: inline">wlang/sql</h3>
|
1060
1226
|
|
1061
|
-
</div>
|
1062
|
-
<div class="dialect">
|
1063
|
-
<div style="margin-bottom: 20px">
|
1064
|
-
<h3 style="display: inline">wlang/sql</h3>
|
1065
1227
|
<p style="display: inline">Includes Basic, Encoding, Imperative, SQL</p>
|
1066
1228
|
|
1067
|
-
|
1229
|
+
</div>
|
1230
|
+
|
1231
|
+
|
1068
1232
|
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
<p style="display: inline">Includes Basic, Encoding, Imperative, SQL</p>
|
1233
|
+
<div class="dialect">
|
1234
|
+
<div style="margin-bottom: 20px">
|
1235
|
+
<h3 style="display: inline">wlang/sql/sybase</h3>
|
1073
1236
|
|
1074
|
-
</
|
1075
|
-
|
1076
|
-
|
1077
|
-
</div>
|
1237
|
+
<p style="display: inline">Includes Basic, Encoding, Imperative, SQL</p>
|
1078
1238
|
|
1239
|
+
</div>
|
1240
|
+
|
1241
|
+
|
1242
|
+
</div>
|
1243
|
+
|
1079
1244
|
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1245
|
+
|
1246
|
+
</div>
|
1247
|
+
|
1248
|
+
|
1249
|
+
<div class="dialect">
|
1250
|
+
<div style="margin-bottom: 20px">
|
1251
|
+
<h3 style="display: inline">wlang/active-string</h3>
|
1085
1252
|
|
1086
|
-
|
1253
|
+
<p style="display: inline">Includes Basic, Imperative</p>
|
1087
1254
|
|
1255
|
+
</div>
|
1256
|
+
|
1257
|
+
|
1258
|
+
</div>
|
1259
|
+
|
1260
|
+
|
1261
|
+
<div class="dialect">
|
1262
|
+
<div style="margin-bottom: 20px">
|
1263
|
+
<h3 style="display: inline">wlang/xhtml</h3>
|
1088
1264
|
|
1089
|
-
</div>
|
1090
|
-
<div class="dialect">
|
1091
|
-
<div style="margin-bottom: 20px">
|
1092
|
-
<h3 style="display: inline">wlang/xhtml</h3>
|
1093
1265
|
<p style="display: inline">Includes Basic, Encoding, Imperative, Buffering, Context, XHtml</p>
|
1094
1266
|
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
</div>
|
1105
|
-
|
1106
|
-
|
1107
|
-
</div>
|
1108
|
-
<div class="dialect">
|
1109
|
-
<div style="margin-bottom: 20px">
|
1110
|
-
<h3 style="display: inline">wlang/dummy</h3>
|
1111
|
-
|
1112
|
-
</div>
|
1113
|
-
|
1267
|
+
</div>
|
1268
|
+
|
1269
|
+
|
1270
|
+
</div>
|
1271
|
+
|
1272
|
+
|
1273
|
+
<div class="dialect">
|
1274
|
+
<div style="margin-bottom: 20px">
|
1275
|
+
<h3 style="display: inline">wlang/yaml</h3>
|
1114
1276
|
|
1115
|
-
|
1277
|
+
<p style="display: inline">Includes Basic, Encoding, Imperative, Buffering, Context, YAML</p>
|
1116
1278
|
|
1279
|
+
</div>
|
1280
|
+
|
1281
|
+
|
1282
|
+
</div>
|
1283
|
+
|
1284
|
+
|
1285
|
+
<div class="dialect">
|
1286
|
+
<div style="margin-bottom: 20px">
|
1287
|
+
<h3 style="display: inline">wlang/ruby</h3>
|
1117
1288
|
|
1118
|
-
|
1119
|
-
<div id="hosting" style="display: none;">
|
1120
|
-
<div class="header">
|
1121
|
-
<h2>Hosting language</h2>
|
1122
|
-
|
1123
|
-
<div class="clear"></div>
|
1124
|
-
</div>
|
1125
|
-
|
1289
|
+
<p style="display: inline">Includes Basic, Encoding, Imperative, Buffering, Context, Ruby</p>
|
1126
1290
|
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
<
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
</tr>
|
1146
|
-
<tr>
|
1147
|
-
<td><em>dialect</em></td>
|
1148
|
-
<td>Basically, <em>dialect</em> is used as a synonym for (programming)
|
1149
|
-
<em>language</em>. However <em>wlang</em> uses a tree of dialects, allowing
|
1150
|
-
specializations: <tt>sql/sybase</tt> for example is the qualified name of a
|
1151
|
-
sub-dialect ‘sybase’ of the ‘sql’ dialect. Dialects
|
1152
|
-
come with associated <em>encoders</em>.</td>
|
1153
|
-
<td style="font-size: 90%;"><tt>sql/sybase</tt></td>
|
1154
|
-
</tr>
|
1155
|
-
<tr>
|
1156
|
-
<td><em>wlang dialect</em></td>
|
1157
|
-
<td>When we talk about a <em>wlang dialect</em>, we are actually refering to
|
1158
|
-
some specialization of the wlang tag-based grammar: <tt>wlang/xhtml</tt>
|
1159
|
-
for example is the templating language <em>wlang</em> proposes to generate
|
1160
|
-
xhtml pages. An example of source code in that dialect has been shown
|
1161
|
-
before. In addition to its encoders a <em>wlang dialect</em> comes with its
|
1162
|
-
sets of <em>tags</em> and associated <em>rules</em>.</td>
|
1163
|
-
<td style="font-size: 90%;"><tt>wlang/xhtml</tt></td>
|
1164
|
-
</tr>
|
1165
|
-
<tr>
|
1166
|
-
<td><em>encoder</em></td>
|
1167
|
-
<td>Text transformation (algorithm) applying some encoding conventions of a
|
1168
|
-
portion of a the target language generated by a dialect. HTML
|
1169
|
-
entities-encoding, SQL’s back-quoting are examples of encoders.
|
1170
|
-
Encoders are accessible through their qualified name (dialect/encoder).</td>
|
1171
|
-
<td style="font-size: 90%;"><tt>xhtml/entities-encoding</tt><br/><tt>sql/single-quoting</tt></td>
|
1172
|
-
</tr>
|
1173
|
-
<tr>
|
1174
|
-
<td><em>ruleset</em></td>
|
1175
|
-
<td>Reusable set of <em>tags</em> associated to <em>rule</em>s.</td>
|
1176
|
-
<td style="font-size: 90%;"><tt>Imperative ruleset</tt><br/><tt>Encoding rulset</tt></td>
|
1177
|
-
</tr>
|
1178
|
-
<tr>
|
1179
|
-
<td><em>wlang tag</em></td>
|
1180
|
-
<td>Special tags in the template, starting with wlang symbols and a number of
|
1181
|
-
wlang blocks. A tag is associated with a wlang rule.</td>
|
1182
|
-
<td style="font-size: 90%;"><tt>${...}</tt><br/><tt>?{...}{...}{...}</tt></td>
|
1183
|
-
</tr>
|
1184
|
-
<tr>
|
1185
|
-
<td><em>rule</em></td>
|
1186
|
-
<td>Transformation semantics of a given <em>tag</em>. When wlang instantiates a
|
1187
|
-
template it simply replaces <em>wlang tags</em> by some <em>replacement
|
1188
|
-
value</em> (which is always a string). This value is computed by the rule
|
1189
|
-
attached to the tag. Rule definition (see Rulesets tab on top of the page)
|
1190
|
-
explicitly describes the number of blocks it expects, in which dialect they
|
1191
|
-
are parsed and instantiated and the way the replacement value is computed.</td>
|
1192
|
-
<td style="font-size: 90%;"><tt>^{wlang/active-string}{...}</tt><br/> Instantiates #1, looking for an
|
1193
|
-
encoder qualified name. Instantiates #2 in the current dialect. Encode
|
1194
|
-
#2’s instantiation using encoder found in (#1) and return the result
|
1195
|
-
as replacement value.</td>
|
1196
|
-
</tr>
|
1197
|
-
<tr>
|
1198
|
-
<td><em>context</em></td>
|
1199
|
-
<td>Some rules allow code to be executed in the <em>hosting language</em> (the
|
1200
|
-
definition explicitly announce it by putting <tt>wlang/hosted</tt> in the
|
1201
|
-
corresponding block). When doing so, this code is in fact executed in a
|
1202
|
-
given context that provides the execution semantics.</td>
|
1203
|
-
<td style="font-size: 90%;"></td>
|
1204
|
-
</tr>
|
1205
|
-
<tr>
|
1206
|
-
<td><em>hosting language</em></td>
|
1207
|
-
<td>language (or framework) that executes wlang. More precisely, the hosting
|
1208
|
-
language is the one that rules what is considered as an executable
|
1209
|
-
expression in tags that relies on some execution semantics (like !{…}
|
1210
|
-
for example). See the ‘Hosting language’ section to learn more.</td>
|
1211
|
-
<td style="font-size: 90%;">ruby</td>
|
1212
|
-
</tr>
|
1291
|
+
</div>
|
1292
|
+
|
1293
|
+
|
1294
|
+
</div>
|
1295
|
+
|
1296
|
+
|
1297
|
+
<div class="dialect">
|
1298
|
+
<div style="margin-bottom: 20px">
|
1299
|
+
<h3 style="display: inline">wlang/dummy</h3>
|
1300
|
+
|
1301
|
+
</div>
|
1302
|
+
|
1303
|
+
|
1304
|
+
</div>
|
1305
|
+
|
1306
|
+
|
1307
|
+
|
1308
|
+
</div>
|
1213
1309
|
|
1214
|
-
|
1310
|
+
<div id="hosting" style="display: none;">
|
1311
|
+
<div class="header">
|
1312
|
+
<h2>Hosting language</h2>
|
1313
|
+
|
1314
|
+
<div class="clear"></div>
|
1315
|
+
</div>
|
1316
|
+
|
1317
|
+
|
1318
|
+
|
1319
|
+
</div>
|
1215
1320
|
|
1321
|
+
<div id="glossary" style="display: none;">
|
1322
|
+
<div class="header">
|
1323
|
+
<h2>Glossary</h2>
|
1324
|
+
|
1325
|
+
<div class="clear"></div>
|
1326
|
+
</div>
|
1327
|
+
|
1328
|
+
<table class="glossary">
|
1329
|
+
<tr>
|
1330
|
+
<th class="term">term</th>
|
1331
|
+
<th class="definition">definition</th>
|
1332
|
+
<th class="example">example</th>
|
1333
|
+
</tr>
|
1334
|
+
|
1335
|
+
<tr>
|
1336
|
+
<td><em>template</em></td>
|
1337
|
+
<td>Source code respecting the wlang grammar, and attached to a given <em>wlang
|
1338
|
+
dialect</em>.</td>
|
1339
|
+
<td style="font-size: 90%;"><tt>Hello ${name}</tt></td>
|
1340
|
+
</tr>
|
1341
|
+
|
1342
|
+
<tr>
|
1343
|
+
<td><em>dialect</em></td>
|
1344
|
+
<td>Basically, <em>dialect</em> is used as a synonym for (programming)
|
1345
|
+
<em>language</em>. However <em>wlang</em> uses a tree of dialects, allowing
|
1346
|
+
specializations: <tt>sql/sybase</tt> for example is the qualified name of a
|
1347
|
+
sub-dialect ‘sybase’ of the ‘sql’ dialect. Dialects
|
1348
|
+
come with associated <em>encoders</em>.</td>
|
1349
|
+
<td style="font-size: 90%;"><tt>sql/sybase</tt></td>
|
1350
|
+
</tr>
|
1351
|
+
|
1352
|
+
<tr>
|
1353
|
+
<td><em>wlang dialect</em></td>
|
1354
|
+
<td>When we talk about a <em>wlang dialect</em>, we are actually refering to
|
1355
|
+
some specialization of the wlang tag-based grammar: <tt>wlang/xhtml</tt>
|
1356
|
+
for example is the templating language <em>wlang</em> proposes to generate
|
1357
|
+
xhtml pages. An example of source code in that dialect has been shown
|
1358
|
+
before. In addition to its encoders a <em>wlang dialect</em> comes with its
|
1359
|
+
sets of <em>tags</em> and associated <em>rules</em>.</td>
|
1360
|
+
<td style="font-size: 90%;"><tt>wlang/xhtml</tt></td>
|
1361
|
+
</tr>
|
1362
|
+
|
1363
|
+
<tr>
|
1364
|
+
<td><em>encoder</em></td>
|
1365
|
+
<td>Text transformation (algorithm) applying some encoding conventions of a
|
1366
|
+
portion of a the target language generated by a dialect. HTML
|
1367
|
+
entities-encoding, SQL’s back-quoting are examples of encoders.
|
1368
|
+
Encoders are accessible through their qualified name (dialect/encoder).</td>
|
1369
|
+
<td style="font-size: 90%;"><tt>xhtml/entities-encoding</tt><br/><tt>sql/single-quoting</tt></td>
|
1370
|
+
</tr>
|
1371
|
+
|
1372
|
+
<tr>
|
1373
|
+
<td><em>ruleset</em></td>
|
1374
|
+
<td>Reusable set of <em>tags</em> associated to <em>rule</em>s.</td>
|
1375
|
+
<td style="font-size: 90%;"><tt>Imperative ruleset</tt><br/><tt>Encoding rulset</tt></td>
|
1376
|
+
</tr>
|
1377
|
+
|
1378
|
+
<tr>
|
1379
|
+
<td><em>wlang tag</em></td>
|
1380
|
+
<td>Special tags in the template, starting with wlang symbols and a number of
|
1381
|
+
wlang blocks. A tag is associated with a wlang rule.</td>
|
1382
|
+
<td style="font-size: 90%;"><tt>${...}</tt><br/><tt>?{...}{...}{...}</tt></td>
|
1383
|
+
</tr>
|
1384
|
+
|
1385
|
+
<tr>
|
1386
|
+
<td><em>rule</em></td>
|
1387
|
+
<td>Transformation semantics of a given <em>tag</em>. When wlang instantiates a
|
1388
|
+
template it simply replaces <em>wlang tags</em> by some <em>replacement
|
1389
|
+
value</em> (which is always a string). This value is computed by the rule
|
1390
|
+
attached to the tag. Rule definition (see Rulesets tab on top of the page)
|
1391
|
+
explicitly describes the number of blocks it expects, in which dialect they
|
1392
|
+
are parsed and instantiated and the way the replacement value is computed.</td>
|
1393
|
+
<td style="font-size: 90%;"><tt>^{wlang/active-string}{...}</tt><br/> Instantiates #1, looking for an
|
1394
|
+
encoder qualified name. Instantiates #2 in the current dialect. Encode
|
1395
|
+
#2’s instantiation using encoder found in (#1) and return the result
|
1396
|
+
as replacement value.</td>
|
1397
|
+
</tr>
|
1398
|
+
|
1399
|
+
<tr>
|
1400
|
+
<td><em>context</em></td>
|
1401
|
+
<td>Some rules allow code to be executed in the <em>hosting language</em> (the
|
1402
|
+
definition explicitly announce it by putting <tt>wlang/hosted</tt> in the
|
1403
|
+
corresponding block). When doing so, this code is in fact executed in a
|
1404
|
+
given context that provides the execution semantics.</td>
|
1405
|
+
<td style="font-size: 90%;"></td>
|
1406
|
+
</tr>
|
1407
|
+
|
1408
|
+
<tr>
|
1409
|
+
<td><em>hosting language</em></td>
|
1410
|
+
<td>language (or framework) that executes wlang. More precisely, the hosting
|
1411
|
+
language is the one that rules what is considered as an executable
|
1412
|
+
expression in tags that relies on some execution semantics (like !{…}
|
1413
|
+
for example). See the ‘Hosting language’ section to learn more.</td>
|
1414
|
+
<td style="font-size: 90%;">ruby</td>
|
1415
|
+
</tr>
|
1416
|
+
|
1417
|
+
</table>
|
1418
|
+
|
1419
|
+
|
1420
|
+
</div>
|
1216
1421
|
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1422
|
+
<div id="symbols" style="display: none;">
|
1423
|
+
<div class="header">
|
1424
|
+
<h2>Tag symbols</h2>
|
1425
|
+
|
1426
|
+
<div class="clear"></div>
|
1427
|
+
</div>
|
1428
|
+
|
1429
|
+
<table class="symbols">
|
1430
|
+
<tr>
|
1431
|
+
<th class="name">name</th>
|
1432
|
+
<th class="symbol">symbol</th>
|
1433
|
+
<th class="meaning">meaning</th>
|
1434
|
+
<th class="remark">remark</th>
|
1435
|
+
</tr>
|
1436
|
+
|
1231
1437
|
<tr>
|
1232
1438
|
<td><em>exclamation mark</em></td>
|
1233
1439
|
<td>!</td>
|
1234
1440
|
<td>execution</td>
|
1235
1441
|
<td>should never be overrided as single</td>
|
1236
1442
|
</tr>
|
1443
|
+
|
1237
1444
|
<tr>
|
1238
1445
|
<td><em>caret/circumflex</em></td>
|
1239
1446
|
<td>^</td>
|
1240
1447
|
<td>explicit encoding</td>
|
1241
1448
|
<td>should never be overrided as single</td>
|
1242
1449
|
</tr>
|
1450
|
+
|
1243
1451
|
<tr>
|
1244
1452
|
<td><em>percent</em></td>
|
1245
1453
|
<td>%</td>
|
1246
1454
|
<td>modulation</td>
|
1247
1455
|
<td>should never be overrided as single</td>
|
1248
1456
|
</tr>
|
1457
|
+
|
1249
1458
|
<tr>
|
1250
1459
|
<td><em>double quote</em></td>
|
1251
1460
|
<td>"</td>
|
1252
1461
|
<td>double-quoting</td>
|
1253
1462
|
<td></td>
|
1254
1463
|
</tr>
|
1464
|
+
|
1255
1465
|
<tr>
|
1256
1466
|
<td><em>dollar</em></td>
|
1257
1467
|
<td>$</td>
|
1258
1468
|
<td>main-encoding</td>
|
1259
1469
|
<td></td>
|
1260
1470
|
</tr>
|
1471
|
+
|
1261
1472
|
<tr>
|
1262
1473
|
<td><em>ampersand</em></td>
|
1263
1474
|
<td>&</td>
|
1264
1475
|
<td>encoding</td>
|
1265
1476
|
<td></td>
|
1266
1477
|
</tr>
|
1478
|
+
|
1267
1479
|
<tr>
|
1268
1480
|
<td><em>single quote</em></td>
|
1269
1481
|
<td>'</td>
|
1270
1482
|
<td>single-quoting</td>
|
1271
1483
|
<td></td>
|
1272
1484
|
</tr>
|
1485
|
+
|
1273
1486
|
<tr>
|
1274
1487
|
<td><em>asterisk</em></td>
|
1275
1488
|
<td>*</td>
|
1276
1489
|
<td>iteration</td>
|
1277
1490
|
<td></td>
|
1278
1491
|
</tr>
|
1492
|
+
|
1279
1493
|
<tr>
|
1280
1494
|
<td><em>plus</em></td>
|
1281
1495
|
<td>+</td>
|
1282
1496
|
<td>inclusion</td>
|
1283
1497
|
<td></td>
|
1284
1498
|
</tr>
|
1499
|
+
|
1285
1500
|
<tr>
|
1286
1501
|
<td><em>question mark</em></td>
|
1287
1502
|
<td>?</td>
|
1288
1503
|
<td>condition</td>
|
1289
1504
|
<td></td>
|
1290
1505
|
</tr>
|
1506
|
+
|
1291
1507
|
<tr>
|
1292
1508
|
<td><em>at symbol</em></td>
|
1293
1509
|
<td>@</td>
|
1294
1510
|
<td>linking</td>
|
1295
1511
|
<td></td>
|
1296
1512
|
</tr>
|
1513
|
+
|
1297
1514
|
<tr>
|
1298
1515
|
<td><em>tilde</em></td>
|
1299
1516
|
<td>~</td>
|
1300
1517
|
<td>matching</td>
|
1301
1518
|
<td></td>
|
1302
1519
|
</tr>
|
1520
|
+
|
1303
1521
|
<tr>
|
1304
1522
|
<td><em>number sign</em></td>
|
1305
1523
|
<td>#</td>
|
1306
1524
|
<td></td>
|
1307
1525
|
<td></td>
|
1308
1526
|
</tr>
|
1527
|
+
|
1309
1528
|
<tr>
|
1310
1529
|
<td><em>comma</em></td>
|
1311
1530
|
<td>,</td>
|
1312
1531
|
<td></td>
|
1313
1532
|
<td></td>
|
1314
1533
|
</tr>
|
1534
|
+
|
1315
1535
|
<tr>
|
1316
1536
|
<td><em>minus (dash)</em></td>
|
1317
1537
|
<td>-</td>
|
1318
1538
|
<td></td>
|
1319
1539
|
<td></td>
|
1320
1540
|
</tr>
|
1541
|
+
|
1321
1542
|
<tr>
|
1322
1543
|
<td><em>dot</em></td>
|
1323
1544
|
<td>.</td>
|
1324
1545
|
<td></td>
|
1325
1546
|
<td></td>
|
1326
1547
|
</tr>
|
1548
|
+
|
1327
1549
|
<tr>
|
1328
1550
|
<td><em>forward slash</em></td>
|
1329
1551
|
<td>/</td>
|
1330
1552
|
<td></td>
|
1331
1553
|
<td></td>
|
1332
1554
|
</tr>
|
1555
|
+
|
1333
1556
|
<tr>
|
1334
1557
|
<td><em>colon</em></td>
|
1335
1558
|
<td>:</td>
|
1336
1559
|
<td></td>
|
1337
1560
|
<td></td>
|
1338
1561
|
</tr>
|
1562
|
+
|
1339
1563
|
<tr>
|
1340
1564
|
<td><em>semi-colon</em></td>
|
1341
1565
|
<td>;</td>
|
1342
1566
|
<td></td>
|
1343
1567
|
<td></td>
|
1344
1568
|
</tr>
|
1569
|
+
|
1345
1570
|
<tr>
|
1346
1571
|
<td><em>equal sign</em></td>
|
1347
1572
|
<td>=</td>
|
1348
1573
|
<td></td>
|
1349
1574
|
<td></td>
|
1350
1575
|
</tr>
|
1576
|
+
|
1351
1577
|
<tr>
|
1352
1578
|
<td><em>less than</em></td>
|
1353
1579
|
<td><</td>
|
1354
1580
|
<td></td>
|
1355
1581
|
<td></td>
|
1356
1582
|
</tr>
|
1583
|
+
|
1357
1584
|
<tr>
|
1358
1585
|
<td><em>greater than</em></td>
|
1359
1586
|
<td>></td>
|
1360
1587
|
<td></td>
|
1361
1588
|
<td></td>
|
1362
1589
|
</tr>
|
1590
|
+
|
1363
1591
|
<tr>
|
1364
1592
|
<td><em>vertical bar</em></td>
|
1365
1593
|
<td>|</td>
|
1366
1594
|
<td></td>
|
1367
1595
|
<td></td>
|
1368
1596
|
</tr>
|
1597
|
+
|
1369
1598
|
<tr>
|
1370
1599
|
<td><em>underscore</em></td>
|
1371
1600
|
<td>_</td>
|
1372
1601
|
<td></td>
|
1373
1602
|
<td>cannot be used as tag symbol; reserved for escaping in future versions</td>
|
1374
1603
|
</tr>
|
1604
|
+
|
1375
1605
|
<tr>
|
1376
1606
|
<td><em>back slash</em></td>
|
1377
1607
|
<td>\</td>
|
1378
1608
|
<td></td>
|
1379
1609
|
<td>cannot be used as tag symbol; reserved for escaping in current version</td>
|
1380
1610
|
</tr>
|
1611
|
+
|
1381
1612
|
<tr>
|
1382
1613
|
<td><em>left parenthesis</em></td>
|
1383
1614
|
<td>(</td>
|
1384
1615
|
<td></td>
|
1385
1616
|
<td>cannot be used as tag symbol; reserved for block delimiter</td>
|
1386
1617
|
</tr>
|
1618
|
+
|
1387
1619
|
<tr>
|
1388
1620
|
<td><em>right parenthesis</em></td>
|
1389
1621
|
<td>)</td>
|
1390
1622
|
<td></td>
|
1391
1623
|
<td>cannot be used as tag symbol; reserved for block delimiter</td>
|
1392
1624
|
</tr>
|
1625
|
+
|
1393
1626
|
<tr>
|
1394
1627
|
<td><em>left bracket</em></td>
|
1395
1628
|
<td>[</td>
|
1396
1629
|
<td></td>
|
1397
1630
|
<td>cannot be used as tag symbol; reserved for block delimiter</td>
|
1398
1631
|
</tr>
|
1632
|
+
|
1399
1633
|
<tr>
|
1400
1634
|
<td><em>right bracket</em></td>
|
1401
1635
|
<td>]</td>
|
1402
1636
|
<td></td>
|
1403
1637
|
<td>cannot be used as tag symbol; reserved for block delimiter</td>
|
1404
1638
|
</tr>
|
1639
|
+
|
1405
1640
|
<tr>
|
1406
1641
|
<td><em>left brace</em></td>
|
1407
1642
|
<td>{</td>
|
1408
1643
|
<td></td>
|
1409
1644
|
<td>cannot be used as tag symbol; reserved for block delimiter</td>
|
1410
1645
|
</tr>
|
1646
|
+
|
1411
1647
|
<tr>
|
1412
1648
|
<td><em>right brace</em></td>
|
1413
1649
|
<td>}</td>
|
1414
1650
|
<td></td>
|
1415
1651
|
<td>cannot be used as tag symbol; reserved for block delimiter</td>
|
1416
1652
|
</tr>
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
</div>
|
1653
|
+
|
1654
|
+
</table>
|
1422
1655
|
|
1656
|
+
|
1657
|
+
</div>
|
1658
|
+
|
1423
1659
|
</body>
|
1424
1660
|
</html>
|