+ will result in one text-element and one tag-element containing one variable-element.
+
+
+
Variable
+
Variables start with a $ or can be wrapped within ${ and }, so vou can write this: ${foo}ish
+
Variable have names, these names can consist of letters (english alphabet; upper and lower case), numbers and underscores (_). As a regex: [a-zA-Z0-9_]+
+
A variable can also be an array. To access an array, wrap the desired fieldname within [ and ]. A fieldname can be constructed of Text and othe Variables. So you can dynamically access fields: $foo[$bar]. These fieldnames can also be nested or concatenated: $foo[$bar[baz]][herp][$de[derp]]
+
If you want a literal $ char, you can escape it: \$
+
Variables in STE T/PL are typeless, everything ist text. In a boolean context, empty text usually represents false, else true.
+
+
Tag
+
A Tag can be compared to a function. A Tag can have parameters and children elements.
+
+ A Tag looks like a XML-Tag with the ste-Namespace.
+ Just like their XML counterparts, they can wrap other elements (barherpdederp]]>) or can be self-closing (]]>).
+ And they can have additional parameters (or "attributes", using the XML terminology): ]]>
+
+
A Tag is wrapped in < and >. The tag's name always start with ste: and can then consist of letters, numbers and underscores (Regex: [a-zA-Z0-9_]+).
+
If the tag is self-closing, the last char is a / (e.g.: ]]>).
+
If the tag is a closing one, the first char is a /. An opening Tag does not have a /.An example of an opening-closing Tag pair wrapping the text bar: bar]]>
+
+ Parameters of a tag consists of a name and the corresponding value (wrapped in " or ') seperated by an = .
+ Parameters are seperated by any whitespace (space, tab or newline) char.
+ Parameter values can consist of Text and Variable elements but not of Tags!
+ If you need a literal " or ' in a parameter value, you can escape them: \" or \' .
+ When using variables in paramter values, they will be "replaced" by their value. Because many tags need the variable and not its content, they expect only the variable's name. If you then write foo="$bar", the tag will not operate on the bar variable but on the Variable with the name stored in $bar! So read the instructions to the tag carefully!
+
+
Example: de ]]>
+
+
Pseudotag
+
Pseudotags look like normal tags, but they perform special tasks. There are currently two pseudotags:
+
ste:comment
+
With the ste:comment pseudotag you can comment your template/code. Everything between <ste:comment> and </ste:comment> will be ignored, before the real tokenization of the code starts.
+
ste:rawtext
+
The ste:rawtext pseudotag will output a Text element with its wrapped content. It will prevent parsing of the content. Useful if you are embedding another script language, which uses the $ char or also has a XML-Like syntax. No escape sequences will be translated! Can not be used in Tag parameter values!
+
+
Escaping special chars
+
To get a literal $, " or other special chars, STE T/PL gives you the following escape sequences:
STE has some builtin Tags, that makes programming in STE T/PL possible.
+
+
ste:if
+
The ste:if Tag provides an if-clause to STE T/PL.
+
ste:if can have the subtags ste:then and ste:else. Everything between <ste:if> and </ste:if>, that is not an ste:then or ste:else tag, will be used as the condition.
+
Because STE T/PL is typeless, every empty string (trailing whitespaces will be ignored) is considered as false, everything else is true.
+
If the condition is true (i.e. not empty), the content of the ste:then block will be executed. Otherwise the ste:else tag (if present) will be executed.
+
The ste:then Tag is mandatory, the ste:else tag is optional.
+
+ Example:
+
+ $foo
+ Bar
+ Baz
+]]>
+ If $foo is not empty, then Bar will be executed, otherwise Baz.
+
+
Short syntax for if-clause
+
Because if-clauses are used often, there is an short syntax:
When this self-closing tag is called, the current loop(ste:for, ste:foreach, ste:infloop) will go to the next iteration, aborting the current iteration.
+
+
ste:load
+
This self-closing tag loads and executes anoter template. The name parameter (mandatory) defines the template to load.
+
Because each template must be parseable and transcompilable by itself, this is not a inclusion of another template. So you can not do this:
+
+ slave.tpl:
+
+ bla]]>
+ master.tpl
+
+]]>
+
+
But you can do this:
+
+ slave.tpl:
+
$bar]]>
+ master.tpl
+
+
+]]>
+
+
+
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 will overwrite the first one.
+
The name can be set with the name parameter.
+
+ Example:
+ master.tpl
+
Content:
+
+ Default content
+
+
+
+ Default sidebar
+
+
]]>
+ slave.tpl:
+
+
+ Much cooler content :-)
+]]>
+ 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.
+
+
Blocks can not be nested.
+
+
ste:set
+
ste:set will set a variable. The parameter var takes the name of the variable to set. The content of the Tag will be the new content of the variable.
+
+ Example:
+
bar]]>
+ This will set the variable foo to bar.
+
+
+ Tag parameter values can not contain Tags. ste:set can be used to bypass this:
+
+]]>
+
+
+
ste:calc
+
To perform mathematical calculations, you can use ste:math. ste:math calculates the mathematical formula it is wrapped around and returns the result. The formula is in the usual infix-notation [ext. Link] and has these operators: +, -, *, / and ^. Numbers are always decimal, the decimal mark is . and numbers can be prefixed with an - to indicate a negative number. It is a good idea to wrap a negative number in brackets to prevent wrong evaluation (because - is also an operator). Calculations can be grouped with brackets: ( and ).
+
Real numbers are supported, complex numbers not.
+
Formulas are evaluated at runtime, not during transcompilation.
This Tag is pretty slow, because the formula is not transcompiled and only evaluated at runtime. For some simple increment and decrement operations it is better to use the ste:inc and ste:dec Tags from the standard library.
+
+
ste:mktag
+
ste:mktag allows you to define own Tags using STE T/PL.
+
The parameter name (mandatory) expects the name of the new tag. If your tag requires some parameters, you can specify them using the optional mandatory parameter. Names of the mandatory parameters are seperated by |.
+
The Variable_tag_parameters (associative array) will hold all given parameters and their values.
+
With the ste:tagcontent tag you can execute the tags content.
+
ste:mktag will be transcompiled like any other code. So your custom tag will be almost as fast as a plugin coded in PHP.
+
+ Example:
+
+
+
+
+
+
+ * 2
+
+
+ $i
+]]>
+ Will output:
+
+8
+6
+4
+2
+0 ]]>
+
+
+
Standard Library
+
The Standard Library contains some useful tags, which are not builtin but still always available.
+
ste:escape
+
Escapes characters that are reserved for HTML (e.g. <, >, ", &). The text to escape ist the tag's content.
+
+ Example:
+
Foo & bar...]]>
+ Result:
+
Foo & bar...]]>
+
+
+
ste:strlen
+
Returns the length of then content.
+
+
ste:arraylen
+
Returns the number of elements in the array (variable name given by parameter array).
+
+
ste:inc
+
Increments (i.e. add 1) a variable (variable name given by parameter var).
+
+
ste:dec
+
Decrements (i.e. substract 1) a variable (variable name given by parameter var).
+
+
ste:date
+
Formats a time using PHPs date format [ext. Link]. The format is given in the tag's content. You can specify a time (unix timestamp) using the timestamp parameter (defaults to the current time).
+
+ Example:
+
d. M. Y, H:i:s]]>
+ Result:
+
+
+
+
diff --git a/docu/nd/Data/ClassHierarchy.nd b/docu/nd/Data/ClassHierarchy.nd
new file mode 100644
index 0000000..2e0591a
Binary files /dev/null and b/docu/nd/Data/ClassHierarchy.nd differ
diff --git a/docu/nd/Data/ConfigFileInfo.nd b/docu/nd/Data/ConfigFileInfo.nd
new file mode 100644
index 0000000..36e0d8c
Binary files /dev/null and b/docu/nd/Data/ConfigFileInfo.nd differ
diff --git a/docu/nd/Data/FileInfo.nd b/docu/nd/Data/FileInfo.nd
new file mode 100644
index 0000000..b0f91a4
--- /dev/null
+++ b/docu/nd/Data/FileInfo.nd
@@ -0,0 +1,3 @@
+1.4
+PHP
+/home/skadu/public_html/stupid_template_engine/stupid_template_engine.php 1316548283 1 stupid_template_engine.php
diff --git a/docu/nd/Data/ImageFileInfo.nd b/docu/nd/Data/ImageFileInfo.nd
new file mode 100644
index 0000000..e6ccf0d
Binary files /dev/null and b/docu/nd/Data/ImageFileInfo.nd differ
diff --git a/docu/nd/Data/ImageReferenceTable.nd b/docu/nd/Data/ImageReferenceTable.nd
new file mode 100644
index 0000000..ad9b847
Binary files /dev/null and b/docu/nd/Data/ImageReferenceTable.nd differ
diff --git a/docu/nd/Data/IndexInfo.nd b/docu/nd/Data/IndexInfo.nd
new file mode 100644
index 0000000..bd66e34
Binary files /dev/null and b/docu/nd/Data/IndexInfo.nd differ
diff --git a/docu/nd/Data/PreviousMenuState.nd b/docu/nd/Data/PreviousMenuState.nd
new file mode 100644
index 0000000..7c0aeba
Binary files /dev/null and b/docu/nd/Data/PreviousMenuState.nd differ
diff --git a/docu/nd/Data/PreviousSettings.nd b/docu/nd/Data/PreviousSettings.nd
new file mode 100644
index 0000000..d319ede
Binary files /dev/null and b/docu/nd/Data/PreviousSettings.nd differ
diff --git a/docu/nd/Data/SymbolTable.nd b/docu/nd/Data/SymbolTable.nd
new file mode 100644
index 0000000..00e4146
Binary files /dev/null and b/docu/nd/Data/SymbolTable.nd differ
diff --git a/docu/nd/Languages.txt b/docu/nd/Languages.txt
new file mode 100644
index 0000000..be96913
--- /dev/null
+++ b/docu/nd/Languages.txt
@@ -0,0 +1,113 @@
+Format: 1.4
+
+# This is the Natural Docs languages file for this project. If you change
+# anything here, it will apply to THIS PROJECT ONLY. If you'd like to change
+# something for all your projects, edit the Languages.txt in Natural Docs'
+# Config directory instead.
+
+
+# You can prevent certain file extensions from being scanned like this:
+# Ignore Extensions: [extension] [extension] ...
+
+
+#-------------------------------------------------------------------------------
+# SYNTAX:
+#
+# Unlike other Natural Docs configuration files, in this file all comments
+# MUST be alone on a line. Some languages deal with the # character, so you
+# cannot put comments on the same line as content.
+#
+# Also, all lists are separated with spaces, not commas, again because some
+# languages may need to use them.
+#
+# Language: [name]
+# Alter Language: [name]
+# Defines a new language or alters an existing one. Its name can use any
+# characters. If any of the properties below have an add/replace form, you
+# must use that when using Alter Language.
+#
+# The language Shebang Script is special. It's entry is only used for
+# extensions, and files with those extensions have their shebang (#!) lines
+# read to determine the real language of the file. Extensionless files are
+# always treated this way.
+#
+# The language Text File is also special. It's treated as one big comment
+# so you can put Natural Docs content in them without special symbols. Also,
+# if you don't specify a package separator, ignored prefixes, or enum value
+# behavior, it will copy those settings from the language that is used most
+# in the source tree.
+#
+# Extensions: [extension] [extension] ...
+# [Add/Replace] Extensions: [extension] [extension] ...
+# Defines the file extensions of the language's source files. You can
+# redefine extensions found in the main languages file. You can use * to
+# mean any undefined extension.
+#
+# Shebang Strings: [string] [string] ...
+# [Add/Replace] Shebang Strings: [string] [string] ...
+# Defines a list of strings that can appear in the shebang (#!) line to
+# designate that it's part of the language. You can redefine strings found
+# in the main languages file.
+#
+# Ignore Prefixes in Index: [prefix] [prefix] ...
+# [Add/Replace] Ignored Prefixes in Index: [prefix] [prefix] ...
+#
+# Ignore [Topic Type] Prefixes in Index: [prefix] [prefix] ...
+# [Add/Replace] Ignored [Topic Type] Prefixes in Index: [prefix] [prefix] ...
+# Specifies prefixes that should be ignored when sorting symbols in an
+# index. Can be specified in general or for a specific topic type.
+#
+#------------------------------------------------------------------------------
+# For basic language support only:
+#
+# Line Comments: [symbol] [symbol] ...
+# Defines a space-separated list of symbols that are used for line comments,
+# if any.
+#
+# Block Comments: [opening sym] [closing sym] [opening sym] [closing sym] ...
+# Defines a space-separated list of symbol pairs that are used for block
+# comments, if any.
+#
+# Package Separator: [symbol]
+# Defines the default package separator symbol. The default is a dot.
+#
+# [Topic Type] Prototype Enders: [symbol] [symbol] ...
+# When defined, Natural Docs will attempt to get a prototype from the code
+# immediately following the topic type. It stops when it reaches one of
+# these symbols. Use \n for line breaks.
+#
+# Line Extender: [symbol]
+# Defines the symbol that allows a prototype to span multiple lines if
+# normally a line break would end it.
+#
+# Enum Values: [global|under type|under parent]
+# Defines how enum values are referenced. The default is global.
+# global - Values are always global, referenced as 'value'.
+# under type - Values are under the enum type, referenced as
+# 'package.enum.value'.
+# under parent - Values are under the enum's parent, referenced as
+# 'package.value'.
+#
+# Perl Package: [perl package]
+# Specifies the Perl package used to fine-tune the language behavior in ways
+# too complex to do in this file.
+#
+#------------------------------------------------------------------------------
+# For full language support only:
+#
+# Full Language Support: [perl package]
+# Specifies the Perl package that has the parsing routines necessary for full
+# language support.
+#
+#-------------------------------------------------------------------------------
+
+# The following languages are defined in the main file, if you'd like to alter
+# them:
+#
+# Text File, Shebang Script, C/C++, C#, Java, JavaScript, Perl, Python,
+# PHP, SQL, Visual Basic, Pascal, Assembly, Ada, Tcl, Ruby, Makefile,
+# ActionScript, ColdFusion, R, Fortran
+
+# If you add a language that you think would be useful to other developers
+# and should be included in Natural Docs by default, please e-mail it to
+# languages [at] naturaldocs [dot] org.
diff --git a/docu/nd/Menu.txt b/docu/nd/Menu.txt
new file mode 100644
index 0000000..85c51af
--- /dev/null
+++ b/docu/nd/Menu.txt
@@ -0,0 +1,60 @@
+Format: 1.4
+
+
+# You can add a title and sub-title to your menu like this:
+# Title: [project name]
+# SubTitle: [subtitle]
+
+# You can add a footer to your documentation like this:
+# Footer: [text]
+# If you want to add a copyright notice, this would be the place to do it.
+
+# You can add a timestamp to your documentation like one of these:
+# Timestamp: Generated on month day, year
+# Timestamp: Updated mm/dd/yyyy
+# Timestamp: Last updated mon day
+#
+# m - One or two digit month. January is "1"
+# mm - Always two digit month. January is "01"
+# mon - Short month word. January is "Jan"
+# month - Long month word. January is "January"
+# d - One or two digit day. 1 is "1"
+# dd - Always two digit day. 1 is "01"
+# day - Day with letter extension. 1 is "1st"
+# yy - Two digit year. 2006 is "06"
+# yyyy - Four digit year. 2006 is "2006"
+# year - Four digit year. 2006 is "2006"
+
+
+# --------------------------------------------------------------------------
+#
+# Cut and paste the lines below to change the order in which your files
+# appear on the menu. Don't worry about adding or removing files, Natural
+# Docs will take care of that.
+#
+# You can further organize the menu by grouping the entries. Add a
+# "Group: [name] {" line to start a group, and add a "}" to end it.
+#
+# You can add text and web links to the menu by adding "Text: [text]" and
+# "Link: [name] ([URL])" lines, respectively.
+#
+# The formatting and comments are auto-generated, so don't worry about
+# neatness when editing the file. Natural Docs will clean it up the next
+# time it is run. When working with groups, just deal with the braces and
+# forget about the indentation and comments.
+#
+# --------------------------------------------------------------------------
+
+
+File: stupid_template_engine.php (stupid_template_engine.php)
+
+Group: Index {
+
+ Index: Everything
+ Class Index: Classes
+ Constant Index: Constants
+ File Index: Files
+ Function Index: Functions
+ Variable Index: Variables
+ } # Group: Index
+
diff --git a/docu/nd/Topics.txt b/docu/nd/Topics.txt
new file mode 100644
index 0000000..b1a9b93
--- /dev/null
+++ b/docu/nd/Topics.txt
@@ -0,0 +1,81 @@
+Format: 1.4
+
+# This is the Natural Docs topics file for this project. If you change anything
+# here, it will apply to THIS PROJECT ONLY. If you'd like to change something
+# for all your projects, edit the Topics.txt in Natural Docs' Config directory
+# instead.
+
+
+# If you'd like to prevent keywords from being recognized by Natural Docs, you
+# can do it like this:
+# Ignore Keywords: [keyword], [keyword], ...
+#
+# Or you can use the list syntax like how they are defined:
+# Ignore Keywords:
+# [keyword]
+# [keyword], [plural keyword]
+# ...
+
+
+#-------------------------------------------------------------------------------
+# SYNTAX:
+#
+# Topic Type: [name]
+# Alter Topic Type: [name]
+# Creates a new topic type or alters one from the main file. Each type gets
+# its own index and behavior settings. Its name can have letters, numbers,
+# spaces, and these charaters: - / . '
+#
+# Plural: [name]
+# Sets the plural name of the topic type, if different.
+#
+# Keywords:
+# [keyword]
+# [keyword], [plural keyword]
+# ...
+# Defines or adds to the list of keywords for the topic type. They may only
+# contain letters, numbers, and spaces and are not case sensitive. Plural
+# keywords are used for list topics. You can redefine keywords found in the
+# main topics file.
+#
+# Index: [yes|no]
+# Whether the topics get their own index. Defaults to yes. Everything is
+# included in the general index regardless of this setting.
+#
+# Scope: [normal|start|end|always global]
+# How the topics affects scope. Defaults to normal.
+# normal - Topics stay within the current scope.
+# start - Topics start a new scope for all the topics beneath it,
+# like class topics.
+# end - Topics reset the scope back to global for all the topics
+# beneath it.
+# always global - Topics are defined as global, but do not change the scope
+# for any other topics.
+#
+# Class Hierarchy: [yes|no]
+# Whether the topics are part of the class hierarchy. Defaults to no.
+#
+# Page Title If First: [yes|no]
+# Whether the topic's title becomes the page title if it's the first one in
+# a file. Defaults to no.
+#
+# Break Lists: [yes|no]
+# Whether list topics should be broken into individual topics in the output.
+# Defaults to no.
+#
+# Can Group With: [type], [type], ...
+# Defines a list of topic types that this one can possibly be grouped with.
+# Defaults to none.
+#-------------------------------------------------------------------------------
+
+# The following topics are defined in the main file, if you'd like to alter
+# their behavior or add keywords:
+#
+# Generic, Class, Interface, Section, File, Group, Function, Variable,
+# Property, Type, Constant, Enumeration, Event, Delegate, Macro,
+# Database, Database Table, Database View, Database Index, Database
+# Cursor, Database Trigger, Cookie, Build Target
+
+# If you add something that you think would be useful to other developers
+# and should be included in Natural Docs by default, please e-mail it to
+# topics [at] naturaldocs [dot] org.
diff --git a/docu/nd/files/stupid_template_engine-php.html b/docu/nd/files/stupid_template_engine-php.html
new file mode 100644
index 0000000..025f28b
--- /dev/null
+++ b/docu/nd/files/stupid_template_engine-php.html
@@ -0,0 +1,88 @@
+
+
+stupid_template_engine.php
+
+
+
+
+
+
+
+
+
+
Parsing a STE T/PL template. You only need this function, if you want to manually transcompile a template.
Parameters
$code
The STE T/PL code.
Returns
An abstract syntax tree, whic can be used with transcompile.
+
+
transcompile
function transcompile(
$ast
) /* Transcompile and add some boilerplate code. */
Transcompiles an abstract syntax tree to PHP.
Parameters
$ast
The abstract syntax tree to transcompile.
Returns
PHP code. The PHP code is an anonymous function expecting a STECore instance as its parameter and returns a string (everything that was not pached into a section).
+
+
Constants
+
+
Template modes
MODE_SOURCE
The Templates source
MODE_TRANSCOMPILED
The transcompiled template
+
+
StorageAccess
An interface. A StorageAccess implementation is used to access the templates from any storage. This means, that you are not limited to store the Templates inside directories, you can also use a database or something else.
Which mode is preferred? One of the <Template modes>. If <MODE_SOURCE>, the raw sourcecode is expected, if <MODE_TRANSCOMPILED> the transcompiled template as a callable function (expecting an STECore instance as first parameter) is expected. If the transcompiled version is not available or older than the source, you can set this parameter to <MODE_SOURCE> and return the source.
Returns
Either the sourcecode or a callable function (first, and only parameter: an STECore instance).
+
+
save
public function save(
$tpl,
$data,
$mode
)
Saves a template.
Parameters
$tpl -The name of the template. $data - The data to be saved. $mode - A <Template mode> constant.
+
+
FilesystemStorageAccess
The default StorageAccess implementation for loading / saving templates into a directory structure.
A callable function (This must tage three parameters: The STECore instance, an associative array of parameters, and a function representing the tags content(This expects the STECore instance as its only parameter and returns its text result, i.e to get the text, you neeed to call this function with the STECore instance as a parameter)).
+
+
call_tag
public function call_tag(
$name,
$params,
$sub
)
Calling a custom tag (builtin ones can not be called)
Parameters
$name
The Tag’s name
$params
Associative array of parameters
$sub
A callable function (expecting an STECore instance as it’s parameter) that represents the tag’s content.
Returns
The output of the tag.
+
+
exectemplate
public function exectemplate(
$tpl
)
Executes a template and returns the result. The huge difference to load is that this function will also output all blocks.
Parameters
$tpl
The name of the template to execute.
Returns
The output of the template.
+
+
get_var_reference
public function &get_var_reference(
$name,
$create_if_not_exist
)
Get a reference to a template variable using a variable name. This can be used,if your custom tag takes a variable name as a parameter.
Parameters
$name
The variables name.
$create_if_not_exist
Should the variable be created, if it does not exist? Otherwise NULL will be returned, if the variable does not exist.
Returns
A Reference to the variable.
+
+
get_var_by_name
public function get_var_by_name(
$name
)
Get a template variable by its name. This can be used,if your custom tag takes a variable name as a parameter.
Parameters
$name
The variables name.
Returns
The variables value.
+
+
load
public function load(
$tpl,
$quiet
=
False
)
Load a template and return its result (blocks not included, use exectemplate for this).
Parameters
$tpl
The name of the template to be loaded.
$quiet
If true, do not output anything and do notmodify the blocks. This can be useful to load custom tags that are programmed in STE T/PL. Default: false.
Returns
The result of the template (if $quiet == false).
+
+
evalbool
public function evalbool(
$txt
)
Test, if a text represents false (an empty / only whitespace text) or true (everything else).