From 9652dcb0a5f4e7667a32205c69aeba509790a61c Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Sun, 13 Sep 2020 22:11:45 +0200 Subject: Get rid of master/slave terminology It's both offensive and kinda inaccurate in this context, so let's replace it! --- docu/language_definition.html | 22 ++++++++++---------- example/templates/src/articles.html | 10 ++++----- example/templates/src/base.html | 41 +++++++++++++++++++++++++++++++++++++ example/templates/src/master.html | 41 ------------------------------------- 4 files changed, 57 insertions(+), 57 deletions(-) create mode 100644 example/templates/src/base.html delete mode 100644 example/templates/src/master.html diff --git a/docu/language_definition.html b/docu/language_definition.html index c99a4b9..20ba5dc 100644 --- a/docu/language_definition.html +++ b/docu/language_definition.html @@ -407,29 +407,29 @@

This self-closing tag loads and executes another template. The name parameter (mandatory) defines the template to load.

Because each template must be parseable and compilable by itself, this is not a inclusion of another template. So you can not do this:

- slave.tpl:
+ sub.tpl:

<ste:foo>
bla
- master.tpl
-
<ste:load name="slave.tpl" />
</ste:foo>
+ base.tpl
+
<ste:load name="sub.tpl" />
</ste:foo>

But you can do this:

- slave.tpl:
+ sub.tpl:

<ste:foo>$bar</ste:foo>
- master.tpl
-
<ste:baz>
<ste:load name="slave.tpl" />
</ste:baz>
+ base.tpl
+
<ste:baz>
<ste:load name="sub.tpl" />
</ste:baz>

ste:block

-

ste:block provides an easy way for writing master templates. Every block has a name. When a block is defined twice, the second one will overwrite the first one.

+

ste:block provides an easy way for writing base templates. Every block has a name. When a block is defined twice, the second one will overwrite the first one.

The name can be set with the name parameter.

Example:
- master.tpl + base.tpl

<h1>Content:</h1>
<ste:block name="content">
Default content
</ste:block>
<div class="sidebar">
<ste:block name="sidebar">
Default sidebar
</ste:block>
</div>
- slave.tpl:
-
<ste:load name="master.tpl" />
<ste:block name="content">
Much cooler content :-)
</ste:block>
- When executing slave.tpl, master.tpl will be loaded and its content block will be replaced with the new one (Much cooler content :-)) but leave the original sidebar block. + sub.tpl:
+
<ste:load name="base.tpl" />
<ste:block name="content">
Much cooler content :-)
</ste:block>
+ When executing sub.tpl, base.tpl will be loaded and its content block will be replaced with the new one (Much cooler content :-)) but leave the original sidebar block.

Blocks can not be nested.

diff --git a/example/templates/src/articles.html b/example/templates/src/articles.html index 36f59c4..270eb00 100644 --- a/example/templates/src/articles.html +++ b/example/templates/src/articles.html @@ -1,5 +1,5 @@ - + Lets overwrite the content section

Some Articles

@@ -29,7 +29,7 @@

There are more articles.

- +

Some more useless demo stuff...

Counting from 10 to 0...

but take only the even ones and multiply by 5...

@@ -41,15 +41,15 @@ - +

Repeat some text...

Bla

- +

Get a variable's content dynamically

- +

We will call ste:repeat with a non-numerical value for n here to see the handling of a RuntimeError

Bla

diff --git a/example/templates/src/base.html b/example/templates/src/base.html new file mode 100644 index 0000000..fe6b1e6 --- /dev/null +++ b/example/templates/src/base.html @@ -0,0 +1,41 @@ + + + + ?{$title|$title - example|example}If $title given, set title to "$title - example", else "example" + + + + +

example

+ +
+ + Default content. + +
+
+ +

List of users

+ Lets loop through the users... +
    + +
  • $user[name] ($user[username])
  • +
    +
+
+
+ + diff --git a/example/templates/src/master.html b/example/templates/src/master.html deleted file mode 100644 index fe6b1e6..0000000 --- a/example/templates/src/master.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - ?{$title|$title - example|example}If $title given, set title to "$title - example", else "example" - - - - -

example

- -
- - Default content. - -
-
- -

List of users

- Lets loop through the users... -
    - -
  • $user[name] ($user[username])
  • -
    -
-
-
- - -- cgit v1.2.3-54-g00ecf