--- title: WLang version: 0.8.4 sections: - id: about name: About file: about.rdoc - id: overview name: Overview file: overview.rdoc - id: rulesets name: Rulesets file: rulesets.wtpl links: 'spec["rulesets"].reverse' - id: dialects name: Dialects file: dialects.wtpl - id: hosting name: Hosting language file: hosting.rdoc - id: glossary name: Glossary file: glossary.wtpl - id: symbols name: Tag symbols file: symbols.wtpl glossary: - term: template definition: |- Source code respecting the wlang grammar, and attached to a given wlang dialect. example: |- Hello ${name} - term: dialect definition: |- Basically, dialect is used as a synonym for (programming) language. However _wlang_ uses a tree of dialects, allowing specializations: sql/sybase for example is the qualified name of a sub-dialect 'sybase' of the 'sql' dialect. Dialects come with associated _encoders_. example: |- sql/sybase - term: wlang dialect definition: |- When we talk about a wlang dialect, we are actually refering to some specialization of the wlang tag-based grammar: wlang/xhtml for example is the templating language _wlang_ proposes to generate xhtml pages. An example of source code in that dialect has been shown before. In addition to its encoders a wlang dialect comes with its sets of _tags_ and associated _rules_. example: |- wlang/xhtml - term: encoder definition: |- Text transformation (algorithm) applying some encoding conventions of a portion of a the target language generated by a dialect. HTML entities-encoding, SQL's back-quoting are examples of encoders. Encoders are accessible through their qualified name (dialect/encoder). example: |- xhtml/entities-encoding
sql/single-quoting - term: ruleset definition: |- Reusable set of tags associated to rules. example: |- Imperative ruleset
Encoding rulset - term: wlang tag definition: |- Special tags in the template, starting with wlang symbols and a number of wlang blocks. A tag is associated with a wlang rule. example: |- ${...}
?{...}{...}{...} - term: rule definition: |- Transformation semantics of a given tag. When wlang instantiates a template it simply replaces wlang tags by some replacement value (which is always a string). This value is computed by the rule attached to the tag. Rule definition (see Rulesets tab on top of the page) explicitly describes the number of blocks it expects, in which dialect they are parsed and instantiated and the way the replacement value is computed. example: |- ^{wlang/active-string}{...}
Instantiates #1, looking for an encoder qualified name. Instantiates #2 in the current dialect. Encode #2's instantiation using encoder found in (#1) and return the result as replacement value. - term: context definition: |- Some rules allow code to be executed in the hosting language (the definition explicitly announce it by putting wlang/hosted in the corresponding block). When doing so, this code is in fact executed in a given context that provides the execution semantics. - term: hosting language definition: |- language (or framework) that executes wlang. More precisely, the hosting language is the one that rules what is considered as an executable expression in tags that relies on some execution semantics (like !{...} for example). See the 'Hosting language' section to learn more. example: |- ruby rulesets: - name: Basic description: |- The Basic ruleset is commonly installed on any dialect and provides access to _wlang_ foundations inside your template: requesting the hosting language to execute some expression, changing the current dialect and encoding text. examples: - ["wlang/active-string", "Hello !{name}", "Hello O'Neil"] - ["wlang/active-string", "Hello %{wlang/dummy}{!{name}}", "Hello !{name}"] - ["wlang/dummy", "Hello %{wlang/dummy}{!{name}}", "Hello %{wlang/dummy}{!{name}}"] - ["wlang/active-string", "Hello ^{plain-text/upcase}{${name}}", "Hello O'NEIL"] rules: # !{wlang/hosted} - name: "execution" symbol: "!" signature: "!{wlang/hosted}" definition: |- Instantiates #1, looking for an expression of the hosting language. Evaluates it, looking for any object. Converts it to a string (using to_s for example if Ruby is the hosting language) and returns the result as replacement value. # %{wlang/active-string}{...} - name: "modulation" symbol: "%" signature: "%{wlang/active-string}{...}" definition: |- Instantiates #1, looking for a dialect qualified name. Instantiates #2 according to the rules defined by that dialect and returns the #2's instantiation as replacement value. # ^{wlang/active-string}{...} - name: "encoding" symbol: "^" signature: "^{wlang/active-string}{...}" definition: |- Instantiates #1, looking for an encoder qualified name. Instantiates #2 in the current dialect. Encode #2's instantiation using encoder found in (#1) and returns encoding as replacement value. # %!{wlang/active-string using ... with ...}{...} - name: "recursive-application" symbol: "%!" signature: "%!{wlang/active-string ? ?}{...}" definition: |- Instantiates #1, looking for a dialect qualified name. Instantiates #2 in the current dialect. Instantiates #2's instantiation in the dialect found in #1, using context installed by 'using ...' and 'with ...'. Returns this instantiation as replacement value (this really advanced rule allows metaprogramming). # ${wlang/hosted} - name: "injection" symbol: "$" signature: "${wlang/hosted}" definition: Same semantics as execution (intended to be overrided). # +{wlang/hosted} - name: "inclusion" symbol: "+" signature: "+{wlang/hosted}" definition: Same semantics as execution (intended to be overrided). - name: Encoding description: |- Almost all languages require escaping/encoding in specific situations: quoted string literals always come with an escaping mechanism (unfortunately different from one language to another), html requires entities-encoding, etc. The Encoding ruleset proposes shortcut tags for encoding. Note that these shortcuts are written in such a way that they don't depend on the effective dialect. _wlang_ hides language and vendors differences! examples: - ["wlang/xhtml", "Hello &{name}", "Hello name"] - ["wlang/xhtml", "Hello &{