From 4cea894ca7aac671b17c3edda176b22ff62b78af Mon Sep 17 00:00:00 2001 From: rafageist Date: Sat, 7 Feb 2026 05:44:44 -0300 Subject: [PATCH 1/9] Update workflow triggers and version number in configuration files --- .github/workflows/phpstan.yml | 3 +-- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 3 +-- composer.json | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 550d4e4..d0df71d 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -1,10 +1,9 @@ name: PHPStan on: - push: - branches: [ "master" ] pull_request: branches: [ "master" ] + workflow_dispatch: concurrency: group: phpstan-${{ github.ref }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9b6280a..0443971 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -140,7 +140,7 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.meta.outputs.tag }} - name: Div ${{ steps.meta.outputs.version }} + name: Div PHP Template Engine ${{ steps.meta.outputs.version }} body_path: ${{ steps.notes.outputs.path }} files: | build/div-${{ steps.meta.outputs.version }}.zip diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d951b2e..8ded508 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,10 +1,9 @@ name: Tests on: - push: - branches: [ "master" ] pull_request: branches: [ "master" ] + workflow_dispatch: concurrency: group: tests-${{ github.ref }} diff --git a/composer.json b/composer.json index 8948782..1ba35ef 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "code generator" ], "homepage": "https://divengine.com", - "version": "6.1.2", + "version": "6.1.3", "authors": [ { "name": "Rafa Rodriguez", From 57b1d49023cbdc38e6dc787af3197e2cf446d9ac Mon Sep 17 00:00:00 2001 From: rafageist Date: Sat, 7 Feb 2026 05:50:32 -0300 Subject: [PATCH 2/9] Add functions for version parsing and release note management; update base tag logic in release notes generation --- docs/ChangeLog/releases/v6.1.3.md | 9 ++++ scripts/generate_release_notes.py | 76 ++++++++++++++++++++++++++++++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 docs/ChangeLog/releases/v6.1.3.md diff --git a/docs/ChangeLog/releases/v6.1.3.md b/docs/ChangeLog/releases/v6.1.3.md new file mode 100644 index 0000000..942e520 --- /dev/null +++ b/docs/ChangeLog/releases/v6.1.3.md @@ -0,0 +1,9 @@ +# Release v6.1.3 +Date: 2026-02-07 + +## Description +TODO: Add release description. + +## Commits +- [Update workflow triggers and version number in configuration files](https://github.com/divengine/div/commit/4cea894ca7aac671b17c3edda176b22ff62b78af) +- [Update ChangeLog for release v6.1.2 to include additional recent commits](https://github.com/divengine/div/commit/930a0f3a4dfb4f0d371f7009663ad8ad3177cd1b) diff --git a/scripts/generate_release_notes.py b/scripts/generate_release_notes.py index cd2b823..357cac9 100644 --- a/scripts/generate_release_notes.py +++ b/scripts/generate_release_notes.py @@ -31,6 +31,68 @@ def get_last_tag(): return run_git(["describe", "--tags", "--abbrev=0"]) +def parse_version(value: str): + value = value.strip() + if value.startswith("v"): + value = value[1:] + match = re.match(r"^(\d+)\.(\d+)\.(\d+)$", value) + if not match: + return None + return tuple(int(part) for part in match.groups()) + + +def list_release_note_versions(): + releases_dir = ROOT / "docs" / "ChangeLog" / "releases" + if not releases_dir.is_dir(): + return [] + versions = [] + for path in releases_dir.glob("v*.md"): + version = parse_version(path.stem) + if version: + versions.append(version) + return versions + + +def get_previous_release_version(current_version: str): + current = parse_version(current_version) + if not current: + return None + candidates = [v for v in list_release_note_versions() if v < current] + if not candidates: + return None + return max(candidates) + + +def format_version(version_tuple): + return ".".join(str(part) for part in version_tuple) + + +def tag_exists(tag: str) -> bool: + output = run_git(["tag", "--list", tag]) + return bool(output.strip()) + + +def get_base_from_previous_notes(version_tuple): + if not version_tuple: + return None + filename = f"v{format_version(version_tuple)}.md" + path = ROOT / "docs" / "ChangeLog" / "releases" / filename + if not path.is_file(): + return None + text = path.read_text(encoding="utf-8").replace("\r\n", "\n") + match = re.search(r"^## Commits\s*$\n(?P.*?)(?=^## |\Z)", text, re.M | re.S) + if not match: + return None + for line in match.group("body").splitlines(): + line = line.strip() + if not line.startswith("-"): + continue + commit_match = re.search(r"/commit/([0-9a-f]{7,40})", line) + if commit_match: + return commit_match.group(1) + return None + + def get_commits(base, head): log = run_git(["log", "--pretty=format:%H\t%s", f"{base}..{head}"]) rows = [] @@ -45,6 +107,8 @@ def get_commits(base, head): subject = subject.strip() if not subject: continue + if subject.lower().startswith("merge"): + continue if len(subject.split()) <= 1: continue rows.append((sha, subject)) @@ -102,7 +166,17 @@ def main(): args = parser.parse_args() version = args.version.strip() or get_version() - base = args.base_tag.strip() or get_last_tag() + base = args.base_tag.strip() + if not base: + prev_version = get_previous_release_version(version) + if prev_version: + prev_tag = f"v{format_version(prev_version)}" + if tag_exists(prev_tag): + base = prev_tag + else: + base = get_base_from_previous_notes(prev_version) + if not base: + base = get_last_tag() head = args.head.strip() or "HEAD" output = args.output.strip() From bddbb0fb97e7d39b16aca5d0c4e6bfcae9711d6b Mon Sep 17 00:00:00 2001 From: rafageist Date: Sat, 7 Feb 2026 06:20:19 -0300 Subject: [PATCH 3/9] Update release notes generation to exclude merge and changelog update commits --- docs/ChangeLog/releases/v6.1.3.md | 2 +- scripts/generate_release_notes.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/ChangeLog/releases/v6.1.3.md b/docs/ChangeLog/releases/v6.1.3.md index 942e520..35c2219 100644 --- a/docs/ChangeLog/releases/v6.1.3.md +++ b/docs/ChangeLog/releases/v6.1.3.md @@ -5,5 +5,5 @@ Date: 2026-02-07 TODO: Add release description. ## Commits +- [Add functions for version parsing and release note management; update base tag logic in release notes generation](https://github.com/divengine/div/commit/57b1d49023cbdc38e6dc787af3197e2cf446d9ac) - [Update workflow triggers and version number in configuration files](https://github.com/divengine/div/commit/4cea894ca7aac671b17c3edda176b22ff62b78af) -- [Update ChangeLog for release v6.1.2 to include additional recent commits](https://github.com/divengine/div/commit/930a0f3a4dfb4f0d371f7009663ad8ad3177cd1b) diff --git a/scripts/generate_release_notes.py b/scripts/generate_release_notes.py index 357cac9..385afea 100644 --- a/scripts/generate_release_notes.py +++ b/scripts/generate_release_notes.py @@ -107,7 +107,10 @@ def get_commits(base, head): subject = subject.strip() if not subject: continue - if subject.lower().startswith("merge"): + subject_lower = subject.lower() + if subject_lower.startswith("merge"): + continue + if subject_lower.startswith("update changelog"): continue if len(subject.split()) <= 1: continue From 756a5c835a86eb5dd1a57400cd108359a4aaa7c3 Mon Sep 17 00:00:00 2001 From: rafageist Date: Sat, 7 Feb 2026 13:16:08 -0300 Subject: [PATCH 4/9] Update documentation: add notes on parsing behavior, loop control, and engine setup variables --- docs/Features/Conditional parts.md | 2 ++ .../Content like an object (intelligent data).md | 2 ++ docs/Features/Lists (loops).md | 13 +++++++++++++ docs/Features/Locations.md | 12 ++++++++++++ docs/Features/Object Oriented Programming.md | 2 ++ docs/Features/System vars.md | 8 ++++++++ docs/Features/Template's variables.md | 2 +- docs/Method's reference.md | 14 ++++++++++++++ docs/README.md | 2 ++ 9 files changed, 56 insertions(+), 1 deletion(-) diff --git a/docs/Features/Conditional parts.md b/docs/Features/Conditional parts.md index f659116..a6e090d 100644 --- a/docs/Features/Conditional parts.md +++ b/docs/Features/Conditional parts.md @@ -20,6 +20,8 @@ In general, the boolean value is defined by the method **div::mixedBool**, whic 6. False if is an object without properties 7. The same value in any other case +Note: the first and last blank space inside conditional blocks are trimmed during parsing. + Syntax: ``` diff --git a/docs/Features/Content like an object (intelligent data).md b/docs/Features/Content like an object (intelligent data).md index 06217e5..2cc6739 100644 --- a/docs/Features/Content like an object (intelligent data).md +++ b/docs/Features/Content like an object (intelligent data).md @@ -1,5 +1,7 @@ The information or content that it is passed to the constructor of the div class, can be an object and/or it can contain objects and you can access to the methods of these objects. The access to those methods to obtain information depends on the context or scope in which is you working. +Internal note: Div merges scope data using a deep-copy helper (historically called `cop`) from `divengine/functions`. This is internal behavior and not part of the public API. + Example: "template scope" index.php diff --git a/docs/Features/Lists (loops).md b/docs/Features/Lists (loops).md index 0f943b9..13ffeb8 100644 --- a/docs/Features/Lists (loops).md +++ b/docs/Features/Lists (loops).md @@ -11,6 +11,19 @@ With a list you can repeat some part of template code and work with each item of [/$listvar] ``` +## Breaking a loop + +You can stop iteration using `@break@`. Anything after the break tag in the loop body is ignored and the loop stops. + +Example: + +``` +[$products] + {?( {$_index} == 3 )?}
@break@ {/?} + {$value}
+[/$products] +``` + **Example:** ``` diff --git a/docs/Features/Locations.md b/docs/Features/Locations.md index dab794d..8a388fd 100644 --- a/docs/Features/Locations.md +++ b/docs/Features/Locations.md @@ -66,3 +66,15 @@ Output ``` + +## Clearing location tags + +By default Div removes location tags after parsing. You can control this during parse cycles with the setup var `div.clear_locations`. + +Example: + +``` +{= div.clear_locations: false =} +``` + +This keeps location tags while composing pre-processed templates; remaining location tags are cleared at the end of the top-level parse. diff --git a/docs/Features/Object Oriented Programming.md b/docs/Features/Object Oriented Programming.md index 6db8ded..0ed51e5 100644 --- a/docs/Features/Object Oriented Programming.md +++ b/docs/Features/Object Oriented Programming.md @@ -2,6 +2,8 @@ In this section you can learn how the programmer can create classes that inherit The constructor should respect the parent's constructor. Change the default constructor is not recommended. IMPORTANT: The recommended way for do something before build is the implementation of [**beforeBuild()** hook](https://divengine.org/docs/div-php-template-engine/features/object-oriented-programming#hooks). +Note: If $src is null and $__src is not set, Div derives the template path from the subclass file name (via Reflection). Example: `MyPage.php` -> `MyPage.tpl` in the same directory. Pass $src explicitly to override this behavior. + ``` addLiteral(["text1", "text2"]);` +- `div.clear_locations`: boolean flag that controls whether location tags are cleared during parse cycles. If false, locations are kept for further composition (useful with pre-processed templates). At the end of the top-level parse, remaining location tags are cleared. + + Example index.php diff --git a/docs/Features/Template's variables.md b/docs/Features/Template's variables.md index 7360a2b..66f463a 100644 --- a/docs/Features/Template's variables.md +++ b/docs/Features/Template's variables.md @@ -60,7 +60,7 @@ Call to method of current PHP class See also [OOP section.](https://divengine.org/documentation/div-php-template-engine/features/templates-variables#oop) -The dollar symbol used to get a variable's value in the JSON, is not the modifier in simple replacements (DIV_TAG_MODIFIER_SIMPLE). This symbol can not be changed with a custom dialect. Is a strict rule in Div. +Note: the `$` used inside template variable values (for example `{= var2: $var1 =}`) is a fixed token and is not affected by dialect changes. Changing `DIV_TAG_MODIFIER_SIMPLE` only affects replacements in template output. Example: diff --git a/docs/Method's reference.md b/docs/Method's reference.md index 730ebca..09913e2 100644 --- a/docs/Method's reference.md +++ b/docs/Method's reference.md @@ -68,6 +68,10 @@ Return a default replacement of value by var Return the [loaded data from the system](https://divengine.org/documentation/div-php-template-engine/methodss-reference#system-vars) +**div::getVersion()** + +Return current engine version string + **div::getVarsFromCode(**string** $code)** Return a list of vars from PHP code @@ -151,3 +155,13 @@ Convert string from UTF16 to UTF18 **div::varExists(**string** \$var, **mixed** &\$items = null)** Return true if var exists in the template's items recursively + +## Instance methods + +**div->addLiteral(**string** $var)** + +Mark one or more template variables as literal (skip further parsing). Accepts a space- or comma-separated list. + +**div->getLiterals()** + +Return the current literal vars map for this instance diff --git a/docs/README.md b/docs/README.md index 8cb45fd..1ad0b2e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,6 +3,8 @@ > Content may be incomplete, subject to change, or restructured as the Div engine evolves. > Please use with caution and check back regularly for updates. +Requirements: PHP >= 8.0. + **div** is a [template engine](https://en.wikipedia.org/wiki/Template_processor) and [code generator tool](https://en.wikipedia.org/wiki/Code_generation_%28compiler%29) tool written in [PHP](http://php.net/) and developed since 2011, designed to optimize collaboration between developers and designers through generative programming, model-driven architecture, and meta-programming. This engine not only facilitates the separation of labor between roles but also allows for deep customization through the creation of tailored template [dialects](https://dialector.divengine.org) to meet specific project needs. ```mermaid From 6e92000055dc530d3f0b05622f5b7dc6ee2bf1be Mon Sep 17 00:00:00 2001 From: rafageist Date: Sat, 7 Feb 2026 20:23:43 -0300 Subject: [PATCH 5/9] Update documentation: enhance the overview and clarify engine behavior and core operations --- .github/workflows/release.yml | 2 +- docs/01 Introduction.md | 32 +++ docs/01.01 Scope and purpose.md | 13 ++ docs/01.02 Engine behavior.md | 19 ++ docs/01.03 Dialect system.md | 13 ++ docs/01.04 Core operations.md | 9 + docs/01.05 Install.md | 5 + docs/01.06 Upgrade.md | 5 + docs/01.07 Related topics.md | 10 + docs/01.09 Goals.md | 7 + docs/01.10 Reasons.md | 11 ++ docs/01.13 The div class.md | 61 ++++++ docs/01.14 The best practices.md | 13 ++ docs/02 Template Features.md | 49 +++++ docs/02.01 Understanding the syntax.md | 47 +++++ ....02 Variables (information, content...).md | 49 +++++ docs/02.03 Simple replacements.md | 43 ++++ ...ments.md => 02.04 Special replacements.md} | 8 +- docs/02.05 Variable's modifiers.md | 113 +++++++++++ ...=> 02.06 Multiple variable's modifiers.md} | 16 +- docs/02.07 String's dissection.md | 37 ++++ .../Data formats.md => 02.08 Data formats.md} | 18 +- docs/02.09 Formulas.md | 34 ++++ ...ists (loops).md => 02.10 Lists (loops).md} | 50 +++-- ...md => 02.11 Dynamic vars inside a loop.md} | 4 + docs/02.12 Iterations.md | 29 +++ docs/02.13 Conditional parts.md | 82 ++++++++ docs/02.14 Conditions.md | 74 +++++++ ...ments.md => 02.15 Default replacements.md} | 37 ++-- ...2.16 Default replacement for a variable.md | 17 ++ docs/02.17 Multi replacements.md | 67 +++++++ docs/02.18 Capsules.md | 61 ++++++ docs/02.19 Locations.md | 81 ++++++++ docs/02.20 Friendly tags.md | 27 +++ .../Comments.md => 02.21 Comments.md} | 17 +- ...22 Ignored parts (escaping Div parsing).md | 35 ++++ ...2.23 Strip or clean the resulting code.md} | 16 +- docs/02.24 HTML to plain text.md | 31 +++ .../Global vars.md => 02.25 Global vars.md} | 35 ++-- ...ctions.md => 02.26 Aggregate functions.md} | 47 +++-- docs/02.27 Macros.md | 88 +++++++++ docs/02.28 Sub-parsers.md | 107 ++++++++++ docs/02.29 Pre-defined sub-parsers.md | 5 + docs/02.30 Sub-parser's events.md | 44 +++++ docs/02.31 System vars.md | 68 +++++++ docs/02.32 Template's variables.md | 123 ++++++++++++ docs/02.33 Template's properties.md | 17 ++ docs/02.34 Template's documentation.md | 63 ++++++ docs/02.35 Including another templates.md | 39 ++++ ...02.36 Including pre-processed templates.md | 63 ++++++ .../Dialects.md => 02.37 Dialects.md} | 20 +- ...dialects.md => 02.38 Multiple dialects.md} | 28 +-- docs/02.39 Dialect translator.md | 46 +++++ docs/02.40 Custom modifiers.md | 44 +++++ docs/02.41 Object Oriented Programming.md | 72 +++++++ ...ntent like an object (intelligent data).md | 160 +++++++++++++++ docs/02.43 Hooks.md | 41 ++++ docs/02.44 The __toString magic method.md | 126 ++++++++++++ ...es (the third parameter of constructor).md | 13 ++ docs/03 PHP Features.md | 171 ++++++++++++++++ docs/04 Mechanisms.md | 7 + docs/04.01 Components.md | 58 ++++++ docs/04.02 Recursion.md | 70 +++++++ docs/04.03 Templates inheritance.md | 90 +++++++++ docs/05 Appendixes.md | 4 + ....01 Appendix A - Allowed PHP functions.md} | 58 +++--- ... Comparison of syntax of Smarty and Div.md | 61 ++++++ docs/Appendixes.md | 2 - ... Comparison of syntax of Smarty and Div.md | 58 ------ docs/Div PHP Template Engine.md | 41 ---- docs/FUTURE.md | 44 ----- docs/Features/Capsules.md | 64 ------ docs/Features/Conditional parts.md | 100 ---------- docs/Features/Conditions.md | 83 -------- ...ntent like an object (intelligent data).md | 183 ------------------ docs/Features/Custom modifiers.md | 45 ----- .../Default replacement for a variable.md | 18 -- docs/Features/Dialect translator.md | 47 ----- docs/Features/Formulas.md | 40 ---- docs/Features/Friendly tags.md | 31 --- docs/Features/HTML to plain text.md | 28 --- docs/Features/Hooks.md | 40 ---- .../Ignored parts (escaping Div parsing).md | 35 ---- docs/Features/Including another templates.md | 45 ----- .../Including pre-processed templates.md | 69 ------- docs/Features/Iterations.md | 29 --- docs/Features/Locations.md | 80 -------- docs/Features/Macros.md | 110 ----------- docs/Features/Multi replacements.md | 69 ------- docs/Features/Object Oriented Programming.md | 98 ---------- docs/Features/Pre-defined sub-parsers.md | 3 - docs/Features/Simple replacements.md | 41 ---- docs/Features/String's dissection.md | 42 ---- docs/Features/Sub-parser's events.md | 47 ----- docs/Features/Sub-parsers.md | 133 ------------- docs/Features/System vars.md | 75 ------- docs/Features/Template's documentation.md | 80 -------- docs/Features/Template's properties.md | 15 -- docs/Features/Template's variables.md | 144 -------------- docs/Features/The __toString magic method.md | 154 --------------- docs/Features/Understanding the syntax.md | 47 ----- docs/Features/Variable's modifiers.md | 125 ------------ .../Variables (information, content...).md | 55 ------ ...es (the third parameter of constructor).md | 11 -- ...Introduction to Div PHP Template Engine.md | 36 ---- docs/Introduction/Goals.md | 6 - .../Possibilities for the designer.md | 23 --- .../Possibilities for the programmer.md | 13 -- docs/Introduction/Reasons.md | 11 -- docs/Mechanisms.md | 6 - docs/Mechanisms/Components.md | 57 ------ docs/Mechanisms/Recursion.md | 77 -------- docs/Mechanisms/Templates inheritance.md | 99 ---------- docs/Method's reference.md | 167 ---------------- docs/Noteworthy Issues.md | 3 - docs/README.md | 82 ++------ docs/Template Engine Features.md | 31 --- docs/The best practices.md | 3 - docs/The div class.md | 61 ------ docs/book-order.txt | 127 ++++++------ {docs/ChangeLog => releases}/CHANGELOG.md | 0 .../ChangeLog/releases => releases}/README.md | 0 .../ChangeLog/releases => releases}/v6.1.2.md | 2 +- .../ChangeLog/releases => releases}/v6.1.3.md | 0 scripts/generate_release_notes.py | 8 +- 125 files changed, 2924 insertions(+), 3229 deletions(-) create mode 100644 docs/01 Introduction.md create mode 100644 docs/01.01 Scope and purpose.md create mode 100644 docs/01.02 Engine behavior.md create mode 100644 docs/01.03 Dialect system.md create mode 100644 docs/01.04 Core operations.md create mode 100644 docs/01.05 Install.md create mode 100644 docs/01.06 Upgrade.md create mode 100644 docs/01.07 Related topics.md create mode 100644 docs/01.09 Goals.md create mode 100644 docs/01.10 Reasons.md create mode 100644 docs/01.13 The div class.md create mode 100644 docs/01.14 The best practices.md create mode 100644 docs/02 Template Features.md create mode 100644 docs/02.01 Understanding the syntax.md create mode 100644 docs/02.02 Variables (information, content...).md create mode 100644 docs/02.03 Simple replacements.md rename docs/{Features/Special replacements.md => 02.04 Special replacements.md} (59%) create mode 100644 docs/02.05 Variable's modifiers.md rename docs/{Features/Multiple variable's modifiers.md => 02.06 Multiple variable's modifiers.md} (54%) create mode 100644 docs/02.07 String's dissection.md rename docs/{Features/Data formats.md => 02.08 Data formats.md} (78%) create mode 100644 docs/02.09 Formulas.md rename docs/{Features/Lists (loops).md => 02.10 Lists (loops).md} (53%) rename docs/{Features/Dynamic vars inside a loop.md => 02.11 Dynamic vars inside a loop.md} (87%) create mode 100644 docs/02.12 Iterations.md create mode 100644 docs/02.13 Conditional parts.md create mode 100644 docs/02.14 Conditions.md rename docs/{Features/Default replacements.md => 02.15 Default replacements.md} (54%) create mode 100644 docs/02.16 Default replacement for a variable.md create mode 100644 docs/02.17 Multi replacements.md create mode 100644 docs/02.18 Capsules.md create mode 100644 docs/02.19 Locations.md create mode 100644 docs/02.20 Friendly tags.md rename docs/{Features/Comments.md => 02.21 Comments.md} (56%) create mode 100644 docs/02.22 Ignored parts (escaping Div parsing).md rename docs/{Features/Strip or clean the resulting code.md => 02.23 Strip or clean the resulting code.md} (50%) create mode 100644 docs/02.24 HTML to plain text.md rename docs/{Features/Global vars.md => 02.25 Global vars.md} (63%) rename docs/{Features/Aggregate functions.md => 02.26 Aggregate functions.md} (50%) create mode 100644 docs/02.27 Macros.md create mode 100644 docs/02.28 Sub-parsers.md create mode 100644 docs/02.29 Pre-defined sub-parsers.md create mode 100644 docs/02.30 Sub-parser's events.md create mode 100644 docs/02.31 System vars.md create mode 100644 docs/02.32 Template's variables.md create mode 100644 docs/02.33 Template's properties.md create mode 100644 docs/02.34 Template's documentation.md create mode 100644 docs/02.35 Including another templates.md create mode 100644 docs/02.36 Including pre-processed templates.md rename docs/{Features/Dialects.md => 02.37 Dialects.md} (77%) rename docs/{Features/Multiple dialects.md => 02.38 Multiple dialects.md} (56%) create mode 100644 docs/02.39 Dialect translator.md create mode 100644 docs/02.40 Custom modifiers.md create mode 100644 docs/02.41 Object Oriented Programming.md create mode 100644 docs/02.42 Content like an object (intelligent data).md create mode 100644 docs/02.43 Hooks.md create mode 100644 docs/02.44 The __toString magic method.md create mode 100644 docs/02.45 Ignore specific variables (the third parameter of constructor).md create mode 100644 docs/03 PHP Features.md create mode 100644 docs/04 Mechanisms.md create mode 100644 docs/04.01 Components.md create mode 100644 docs/04.02 Recursion.md create mode 100644 docs/04.03 Templates inheritance.md create mode 100644 docs/05 Appendixes.md rename docs/{Appendixes/Appendix A - Allowed PHP functions.md => 05.01 Appendix A - Allowed PHP functions.md} (60%) create mode 100644 docs/05.02 Appendix B - Comparison of syntax of Smarty and Div.md delete mode 100644 docs/Appendixes.md delete mode 100644 docs/Appendixes/Appendix B - Comparison of syntax of Smarty and Div.md delete mode 100644 docs/Div PHP Template Engine.md delete mode 100644 docs/FUTURE.md delete mode 100644 docs/Features/Capsules.md delete mode 100644 docs/Features/Conditional parts.md delete mode 100644 docs/Features/Conditions.md delete mode 100644 docs/Features/Content like an object (intelligent data).md delete mode 100644 docs/Features/Custom modifiers.md delete mode 100644 docs/Features/Default replacement for a variable.md delete mode 100644 docs/Features/Dialect translator.md delete mode 100644 docs/Features/Formulas.md delete mode 100644 docs/Features/Friendly tags.md delete mode 100644 docs/Features/HTML to plain text.md delete mode 100644 docs/Features/Hooks.md delete mode 100644 docs/Features/Ignored parts (escaping Div parsing).md delete mode 100644 docs/Features/Including another templates.md delete mode 100644 docs/Features/Including pre-processed templates.md delete mode 100644 docs/Features/Iterations.md delete mode 100644 docs/Features/Locations.md delete mode 100644 docs/Features/Macros.md delete mode 100644 docs/Features/Multi replacements.md delete mode 100644 docs/Features/Object Oriented Programming.md delete mode 100644 docs/Features/Pre-defined sub-parsers.md delete mode 100644 docs/Features/Simple replacements.md delete mode 100644 docs/Features/String's dissection.md delete mode 100644 docs/Features/Sub-parser's events.md delete mode 100644 docs/Features/Sub-parsers.md delete mode 100644 docs/Features/System vars.md delete mode 100644 docs/Features/Template's documentation.md delete mode 100644 docs/Features/Template's properties.md delete mode 100644 docs/Features/Template's variables.md delete mode 100644 docs/Features/The __toString magic method.md delete mode 100644 docs/Features/Understanding the syntax.md delete mode 100644 docs/Features/Variable's modifiers.md delete mode 100644 docs/Features/Variables (information, content...).md delete mode 100644 docs/Ignore specific variables (the third parameter of constructor).md delete mode 100644 docs/Introduction to Div PHP Template Engine.md delete mode 100644 docs/Introduction/Goals.md delete mode 100644 docs/Introduction/Possibilities for the designer.md delete mode 100644 docs/Introduction/Possibilities for the programmer.md delete mode 100644 docs/Introduction/Reasons.md delete mode 100644 docs/Mechanisms.md delete mode 100644 docs/Mechanisms/Components.md delete mode 100644 docs/Mechanisms/Recursion.md delete mode 100644 docs/Mechanisms/Templates inheritance.md delete mode 100644 docs/Method's reference.md delete mode 100644 docs/Noteworthy Issues.md delete mode 100644 docs/Template Engine Features.md delete mode 100644 docs/The best practices.md delete mode 100644 docs/The div class.md rename {docs/ChangeLog => releases}/CHANGELOG.md (100%) rename {docs/ChangeLog/releases => releases}/README.md (100%) rename {docs/ChangeLog/releases => releases}/v6.1.2.md (97%) rename {docs/ChangeLog/releases => releases}/v6.1.3.md (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0443971..e3ce6cf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -103,7 +103,7 @@ jobs: from pathlib import Path version = os.environ["RELEASE_VERSION"] - notes = Path("docs/ChangeLog/releases") / f"v{version}.md" + notes = Path("releases") / f"v{version}.md" if not notes.is_file(): raise SystemExit( diff --git a/docs/01 Introduction.md b/docs/01 Introduction.md new file mode 100644 index 0000000..c47e4c4 --- /dev/null +++ b/docs/01 Introduction.md @@ -0,0 +1,32 @@ +# 1. Introduction + +Div is a template engine that runs in PHP. + +At its core, Div takes a template and a data model and produces text: + +```php +echo new div($template, $data); +``` + +That is the fundamental contract. The output is always text. + +Div is also used as a code generator and a data transformation tool because templates are not limited to HTML. A template can generate source code, configuration files, structured data, or even other templates. What Div generates can be reused as input for subsequent executions of the engine. + +Div is the cornerstone of Divengine Software Solutions and has been developed continuously since 2011. + +The template language is designed to be compact (minimal syntax for common operations), flexible (dialects allow alternative syntaxes), and descriptive (templates read as self-explanatory documents). Div assumes a clear division of concerns: + +- The model specifies what data and rules are available. +- The template specifies the expected output structure. +- The engine provides the execution mechanism. + +Capabilities span both template authoring and system integration: + +- Variable replacement, formatting, modifiers, substring operations, and object property access within the provided model. +- Lists, iterations, conditional blocks, and other repetitive or branching constructs. +- Includes, inheritance, locations, and recursive processing until convergence. +- Formulas, macros, aggregate functions, and output cleanup (including HTML-to-text conversion). +- Configuration of defaults, globals, allowed functions, and ignored variables. +- Custom sub-parsers, hooks, logging, and use of a div instance as a string. + +When applied consistently, this approach reduces repetitive work, enables reuse of models, supports multi-target outputs, and improves collaboration across stakeholders. diff --git a/docs/01.01 Scope and purpose.md b/docs/01.01 Scope and purpose.md new file mode 100644 index 0000000..a3feec3 --- /dev/null +++ b/docs/01.01 Scope and purpose.md @@ -0,0 +1,13 @@ +# 1.1 Scope and purpose + +Div is designed to support workflows based on templates and models, reduce repetition, and enable consistent generation of text-based outputs. + +Because the output of the engine is plain text, it can be reused freely: + +- as another template, +- as a data model (for example, JSON), +- or as part of a composed result. + +This makes it possible to chain executions, build generation pipelines, transform data through templates, and compose multiple outputs into a final result. Code generation, data transformation, and multi-stage compilation all emerge naturally from this model. + +In server-side rendering for websites, Div can also be used to maintain a clear separation between logic and presentation by keeping templates focused on structure and models focused on data. \ No newline at end of file diff --git a/docs/01.02 Engine behavior.md b/docs/01.02 Engine behavior.md new file mode 100644 index 0000000..7b22a36 --- /dev/null +++ b/docs/01.02 Engine behavior.md @@ -0,0 +1,19 @@ +# 1.2 Engine behavior + +Div does not process templates in a single top-down pass. + +Instead, the engine repeatedly parses and transforms the entire template until no further changes can be made. Each cycle applies the parsing rules (includes, conditions, loops, replacements, modifiers, and related blocks) to the current state of the template. + +The process stops when a stable result is reached (a fixed point) or when a safety limit is met. + +Pseudo-code (conceptual): + +```text +template = original +do: + previous = template + template = parse_pass(template, data) +while template != previous and cycles < MAX +``` + +This iterative behavior allows templates to generate intermediate structures that are evaluated in later cycles. As a result, Div supports meta-templates and templates that generate other templates without relying on recursive calls or hidden execution state. \ No newline at end of file diff --git a/docs/01.03 Dialect system.md b/docs/01.03 Dialect system.md new file mode 100644 index 0000000..3fbfa42 --- /dev/null +++ b/docs/01.03 Dialect system.md @@ -0,0 +1,13 @@ +# 1.3 Dialect system + +Div supports multiple template dialects. + +A dialect is defined externally as a JSON file. It describes how an alternative template syntax maps to Div’s canonical internal syntax. Dialects do not change the engine or its behavior; they only affect how template syntax is interpreted. + +Templates can reference which dialect they are written in using a dedicated tag. This allows different templates, or included fragments, to use different dialects within the same execution. + +Dialect translation occurs before parsing, so the internal parser remains consistent regardless of the syntax used in source templates. This makes it possible to: + +- avoid syntax collisions with the language or format being generated, +- preserve validity constraints (such as XML-valid templates), +- and work with multiple syntactic conventions in a single generation pipeline. \ No newline at end of file diff --git a/docs/01.04 Core operations.md b/docs/01.04 Core operations.md new file mode 100644 index 0000000..3d170e2 --- /dev/null +++ b/docs/01.04 Core operations.md @@ -0,0 +1,9 @@ +# 1.4 Core operations + +Div exposes three fundamental operations: + +- Compile: merge a template with a model and produce text output. +- Transform: generate a new model by reusing compilation. +- Compose: combine the results of multiple executions into a single deliverable. + +These operations can be freely combined to build complex generation and transformation workflows. \ No newline at end of file diff --git a/docs/01.05 Install.md b/docs/01.05 Install.md new file mode 100644 index 0000000..b062541 --- /dev/null +++ b/docs/01.05 Install.md @@ -0,0 +1,5 @@ +# 1.5 Install + +```bash +composer require divengine/div +``` \ No newline at end of file diff --git a/docs/01.06 Upgrade.md b/docs/01.06 Upgrade.md new file mode 100644 index 0000000..d7bbdc1 --- /dev/null +++ b/docs/01.06 Upgrade.md @@ -0,0 +1,5 @@ +# 1.6 Upgrade + +```bash +composer upgrade +``` \ No newline at end of file diff --git a/docs/01.07 Related topics.md b/docs/01.07 Related topics.md new file mode 100644 index 0000000..e2521db --- /dev/null +++ b/docs/01.07 Related topics.md @@ -0,0 +1,10 @@ +# 1.7 Related topics + +[[01.13 The div class]] +[[01.14 The best practices]] +[[02 Template Features]] +[[03 PHP Features]] +[[04 Mechanisms]] +[[05 Appendixes]] + +See also [CHANGELOG](../releases/CHANGELOG.md). diff --git a/docs/01.09 Goals.md b/docs/01.09 Goals.md new file mode 100644 index 0000000..8bba678 --- /dev/null +++ b/docs/01.09 Goals.md @@ -0,0 +1,7 @@ +# 1.9 Goals + +- Maintain a single, cohesive class and file for the engine core. +- Provide a minimal and expressive template syntax. +- Avoid mandatory caching by design. +- Improve parsing algorithms over time. +- Encourage reuse of mechanisms and domain knowledge. \ No newline at end of file diff --git a/docs/01.10 Reasons.md b/docs/01.10 Reasons.md new file mode 100644 index 0000000..4f0bda0 --- /dev/null +++ b/docs/01.10 Reasons.md @@ -0,0 +1,11 @@ +# 1.10 Reasons + +Div was developed to reuse existing developer knowledge rather than introduce a new, complex template language. The goal is to reduce the learning curve while preserving expressive power. + +Features are added only when they are necessary and when they cannot be implemented through existing mechanisms. When a new mechanism is required, the intent is to document it with a clear, reproducible example. + +Performance tests indicated that direct string replacement is faster than invoking PHP includes in many scenarios. Although string replacement can use more memory, the tradeoff is acceptable for typical template sizes. + +Div also avoids a mandatory caching subsystem. Given its deterministic parsing behavior, learning or memoization strategies can be applied externally when needed. + +Finally, the engine is implemented as a single class in a single file to simplify integration into diverse environments. \ No newline at end of file diff --git a/docs/01.13 The div class.md b/docs/01.13 The div class.md new file mode 100644 index 0000000..2c2604e --- /dev/null +++ b/docs/01.13 The div class.md @@ -0,0 +1,61 @@ +# 1.13 The div class + +All engine functionality is provided through the div class. If your project already defines a class named div, you can rename the Div class or use a namespace alias. + +## 4.1 Setup and namespace + +```php + 'Peter' +]); +``` + +2. Instantiate first, render later + +```php +$t = new div('Hello {$name}', ['name' => 'Peter']); + +echo $t; /* or $t->show(); */ +``` + +3. Template from external file + +```php +/* The file index.tpl contains the template code */ + +echo new div('index.tpl', ['name' => 'Peter']); +``` + +4. Data provided as JSON string + +```php +echo new div('Hello {$name}', '{name: "Peter"}'); +``` + +5. Data loaded from a JSON file + +```php +/* The file index.json contains the data as JSON */ + +echo new div('index.tpl', 'index.json'); +``` + +Related topics: + +[[02.45 Ignore specific variables (the third parameter of constructor)]] \ No newline at end of file diff --git a/docs/01.14 The best practices.md b/docs/01.14 The best practices.md new file mode 100644 index 0000000..64ddca2 --- /dev/null +++ b/docs/01.14 The best practices.md @@ -0,0 +1,13 @@ +# 1.14 The best practices + +## 5.1 Keep business logic out of templates + +Templates should not compute domain totals or infer missing data. For example, invoice totals should be computed in PHP and passed to the template. The template language is intended for presentation, not for deriving business rules. + +## 5.2 Balance template and data responsibilities + +Avoid passing excessive data that the template will never use, and avoid placing excessive logic in templates that the engine will discard. Keep the data model and the template in balance so each does only what it is designed for. + +## 5.3 Prefer small, reusable templates + +Split templates into focused components that serve a single purpose. Do not place unrelated layouts in one file with large conditional blocks. If multiple layouts are needed, use includes or pre-processed templates to compose them intentionally. \ No newline at end of file diff --git a/docs/02 Template Features.md b/docs/02 Template Features.md new file mode 100644 index 0000000..2ebc2b3 --- /dev/null +++ b/docs/02 Template Features.md @@ -0,0 +1,49 @@ +# 2. Template Features + +This chapter enumerates the core language features and links to their detailed specifications. + +- [[02.01 Understanding the syntax]] +- [[02.02 Variables (information, content...)]] +- [[02.03 Simple replacements]] +- [[02.04 Special replacements]] +- [[02.05 Variable's modifiers]] +- [[02.06 Multiple variable's modifiers]] +- [[02.07 String's dissection]] +- [[02.08 Data formats]] +- [[02.09 Formulas]] +- [[02.10 Lists (loops)]] +- [[02.11 Dynamic vars inside a loop]] +- [[02.12 Iterations]] +- [[02.13 Conditional parts]] +- [[02.14 Conditions]] +- [[02.15 Default replacements]] +- [[02.16 Default replacement for a variable]] +- [[02.17 Multi replacements]] +- [[02.18 Capsules]] +- [[02.19 Locations]] +- [[02.20 Friendly tags]] +- [[02.21 Comments]] +- [[02.22 Ignored parts (escaping Div parsing)]] +- [[02.23 Strip or clean the resulting code]] +- [[02.24 HTML to plain text]] +- [[02.25 Global vars]] +- [[02.26 Aggregate functions]] +- [[02.27 Macros]] +- [[02.28 Sub-parsers]] +- [[02.29 Pre-defined sub-parsers]] +- [[02.30 Sub-parser's events]] +- [[02.31 System vars]] +- [[02.32 Template's variables]] +- [[02.33 Template's properties]] +- [[02.34 Template's documentation]] +- [[02.35 Including another templates]] +- [[02.36 Including pre-processed templates]] +- [[02.37 Dialects]] +- [[02.38 Multiple dialects]] +- [[02.39 Dialect translator]] +- [[02.40 Custom modifiers]] +- [[02.41 Object Oriented Programming]] +- [[02.42 Content like an object (intelligent data)]] +- [[02.43 Hooks]] +- [[02.44 The __toString magic method]] +- [[02.45 Ignore specific variables (the third parameter of constructor)]] diff --git a/docs/02.01 Understanding the syntax.md b/docs/02.01 Understanding the syntax.md new file mode 100644 index 0000000..f0439a6 --- /dev/null +++ b/docs/02.01 Understanding the syntax.md @@ -0,0 +1,47 @@ +# 2.1 Understanding the syntax + +Div recognizes a small set of block structures. The classification is based on how opening and closing tags are formed and whether whitespace is significant. + +## 6.1.1 Rigid blocks + +|Prefix|Rigid syntax|Suffix| +|---|---|---| +|PREFIX|RIGID SYNTAX|SUFFIX| + +Rigid blocks treat every character as significant. Spaces, tabs, and newlines are part of the syntax and cannot be inserted for formatting. For example, in `{$text }` the variable name includes the trailing space, so the engine looks for `text ` rather than `text`. + +Typical rigid blocks: [[02.03 Simple replacements]], [[02.35 Including another templates]]. + +## 6.1.2 Simple blocks + +|Begin|Flexible syntax|End| +|---|---|---| +|BEGIN|FLEXIBLE SYNTAX|END| + +Simple blocks allow extra whitespace for readability. The opening and closing tags are required, but the content inside the tags is parsed with flexible spacing rules. + +Typical simple blocks: [[02.22 Ignored parts (escaping Div parsing)]], [[02.21 Comments]], [[02.23 Strip or clean the resulting code]]. + +## 6.1.3 No-keyword blocks + +|Begin prefix|Flexible syntax|Begin suffix| +|---|---|---| +|BEGIN_PREFIX|FLEXIBLE SYNTAX|BEGIN_SUFFIX| +|ANY CODE + SPECIAL TAGS||| +|END||| + +No-keyword blocks encode the opening tag using a prefix and suffix, while the closing tag does not repeat the keyword. This form is used when the closing tag is unambiguous. + +Typical no-keyword blocks: [[02.14 Conditions]], [[02.12 Iterations]]. + +## 6.1.4 Keyword blocks + +|Begin prefix|Keyword|Begin suffix| +|---|---|---| +|BEGIN_PREFIX|KEYWORD|BEGIN_SUFFIX| +|ANY CODE + SPECIAL TAGS||| +|END_PREFIX|KEYWORD|END_SUFFIX| + +Keyword blocks repeat the keyword in both the opening and closing tags. This form is used when the block is anchored to a specific variable or identifier. + +Typical keyword blocks: [[02.13 Conditional parts]], [[02.10 Lists (loops)]]. \ No newline at end of file diff --git a/docs/02.02 Variables (information, content...).md b/docs/02.02 Variables (information, content...).md new file mode 100644 index 0000000..79a90e5 --- /dev/null +++ b/docs/02.02 Variables (information, content...).md @@ -0,0 +1,49 @@ +# 2.2 Variables (information, content...) + +Templates operate on "information" rather than strict data types. Arrays and objects are normalized so that both can be accessed uniformly. Nested values are accessed with the dot operator. + +Example: + +**index.php** + +```php + 'something', + 'complex' => [ + 'single' => 45, + 'subcomplex' => [ + 'single' => 60 + ] + ] +]); + +$complex = (object) [ + 'single' => 45, + 'subcomplex' => ['single' => 60] +]; + +echo new div('index.tpl', [ + 'single' => 'something', + 'complex' => $complex +]); +``` + +**index.tpl** + +```php +Single value: {$single} +Single value into complex var: {$complex.single} +And more: {$complex.subcomplex.single} +``` + +**Output** + +```php +Single value: something +Single value into complex var: 45 +And more: 60 +``` + +Related topic: [[02.07 String's dissection]]. \ No newline at end of file diff --git a/docs/02.03 Simple replacements.md b/docs/02.03 Simple replacements.md new file mode 100644 index 0000000..8a21c2d --- /dev/null +++ b/docs/02.03 Simple replacements.md @@ -0,0 +1,43 @@ +# 2.3 Simple replacements + +A simple replacement substitutes a variable with its value. The replacement depends on the value type: + +1. String: the string content. +2. Number: the numeric value. +3. Array: the array length. +4. Object without `__toString`: the number of object properties. + +**Syntax** + +``` +{$varname} +``` + +**Example** + +**index.php** + +```php + 'Peter', + 'last_name' => 'Pan' +]); +``` + +**index.tpl** + +``` +First name: {$first_name} +Last name: {$last_name} +``` + +**Output** + +``` +First name: Peter +Last name: Pan +``` \ No newline at end of file diff --git a/docs/Features/Special replacements.md b/docs/02.04 Special replacements.md similarity index 59% rename from docs/Features/Special replacements.md rename to docs/02.04 Special replacements.md index e4d7f69..e70b1d7 100644 --- a/docs/Features/Special replacements.md +++ b/docs/02.04 Special replacements.md @@ -1,4 +1,6 @@ -Tags for output special characters that can be used always. The following table show the available tags and their replacements: +# 2.4 Special replacements + +Special replacements emit control characters that are otherwise difficult to write in templates. |Tag|Replacement| |---|---| @@ -9,7 +11,7 @@ Tags for output special characters that can be used always. The following table |{\f}|\f| |{\$}|$| -**Example:** +**Example** index.tpl @@ -24,4 +26,4 @@ Output Hello Peter Today is 2013-07-24 -``` +``` \ No newline at end of file diff --git a/docs/02.05 Variable's modifiers.md b/docs/02.05 Variable's modifiers.md new file mode 100644 index 0000000..4eaf323 --- /dev/null +++ b/docs/02.05 Variable's modifiers.md @@ -0,0 +1,113 @@ +# 2.5 Variable's modifiers + +Modifiers transform a variable or derive information from its value. The modifier is placed between the opening brace and the variable name. + +**Syntax** + +|Modifier|Description| +|---|---| +|{$variable}|No transformation| +|{^variable}|Capitalize the first character| +|{^^variable}|Capitalize the first character of each word| +|{^^^variable}|Uppercase| +|{_variable}|Lowercase| +|{%variable}|Character count| +|{%%variable}|Word count| +|{%%%variable}|Sentence count| +|{%%%%variable}|Paragraph count| +|{&variable}|URL encode (see `urlencode`)| +|{&&variable}|Raw URL encode (see `rawurlencode`)| +|{html:variable}|HTML entities (see `htmlentities`)| +|{br:variable}|Convert new lines to `
` (see `nl2br`)| +|{json:variable}|JSON encode| +|{[mod]variable:~truncate-length}|Truncate; if `` exists, truncate there| +|{[mod]variable:/wordwrap-length}|Word wrap| +|{[mod]variable:from,length}|Substring| +|{'variable}|Escape unescaped single quotes| +|{js:variable}|Escape JavaScript strings| +|{$variable:[format]}|Format using `sprintf`| + +**Example** + +index.tpl + +```html +{= title: mozilla firefox =} +{= body: A wonderful web browser =} + +Nothing to change: +{$title} + +Capitalize the first character: +{^title} + +Capitalize each word: +{^^title} + +Uppercase: +{^^^title} + +Lowercase: +{_title} + +Character count: +{%title} + +Substring: +{$body:0,11} + +Truncate: +{$body:~25}... + +Word wrap: +{$body:/30} + +Combined modifiers: +{^^^body:0,11} +{^^^body:/40} + +String format: +{= value: 10 =} +{$value:%1$04d} +``` + +Output + +```html +Nothing to change: +mozilla firefox + +Capitalize the first character: +Mozilla firefox + +Capitalize each word: +Mozilla Firefox + +Uppercase: +MOZILLA FIREFOX + +Lowercase: +mozilla firefox + +Character count: +15 + +Substring: +web browser + +Truncate: +A wonderful... + +Word wrap: +A wonderful web browser + +Combined modifiers: +A WONDERFUL WEB BROWSER + +A WONDERFUL + +String format: +0010 +``` + +Related topics: [[02.40 Custom modifiers]], [[02.06 Multiple variable's modifiers]]. \ No newline at end of file diff --git a/docs/Features/Multiple variable's modifiers.md b/docs/02.06 Multiple variable's modifiers.md similarity index 54% rename from docs/Features/Multiple variable's modifiers.md rename to docs/02.06 Multiple variable's modifiers.md index e881381..3272ae9 100644 --- a/docs/Features/Multiple variable's modifiers.md +++ b/docs/02.06 Multiple variable's modifiers.md @@ -1,27 +1,31 @@ -**Syntax:** +# 2.6 Multiple variable's modifiers + +Multiple modifiers can be chained using the pipe separator. + +**Syntax** ``` {$varname|modifier1|modifier2|modifier3|...|} ``` -**Example:** +**Example** -**index.tpl** +index.tpl ``` {= word: "ABCDEFG" =} - + {$word|0,3|} {$word|0,3|_|} {$word|0,3|_|^|} {$word|0,3|_|^|~2|} ``` -**Output:** +**Output** ``` ABC abc Abc Ab -``` +``` \ No newline at end of file diff --git a/docs/02.07 String's dissection.md b/docs/02.07 String's dissection.md new file mode 100644 index 0000000..8eb4583 --- /dev/null +++ b/docs/02.07 String's dissection.md @@ -0,0 +1,37 @@ +# 2.7 String's dissection + +Scalar values can be treated as strings and accessed as sequences of characters. You can access individual characters using dot notation and iterate over them as if they were a list. + +Example + +``` +{= name: "Peter" =} + +{$name.0} +{$name.1} + +{= x: 537 =} + +{$x.0} +{$x.1} + +[$name]{$value} [/$name] + +[$x] {$value} * [/$x] = (# [$x] {$value} * [/$x] 1 #) +``` + +Output + +``` +P + +e + +5 + +3 + +P e t e r + +5 * 3 * 7 = 105 +``` \ No newline at end of file diff --git a/docs/Features/Data formats.md b/docs/02.08 Data formats.md similarity index 78% rename from docs/Features/Data formats.md rename to docs/02.08 Data formats.md index 70bf05e..99e4c13 100644 --- a/docs/Features/Data formats.md +++ b/docs/02.08 Data formats.md @@ -1,14 +1,16 @@ -The data formats are [[Variable's modifiers]] that need more information than a symbol. +# 2.8 Data formats -**Date format {Format a timestamp}** +Data formats are modifiers that require parameters beyond a single symbol. -Syntax in templates +## 6.8.1 Date format + +**Syntax** ```html {/variable:php-format-date/} ``` -Example +**Example** index.php @@ -32,15 +34,15 @@ Today is: 2012-07-10 Now is: 05:48:20 ``` -**Number format** +## 6.8.2 Number format -Syntax in templates +**Syntax** ```html -{#variable:decimals separator miles-separator#} +{#variable:decimals separator thousands-separator#} ``` -Example +**Example** index.php diff --git a/docs/02.09 Formulas.md b/docs/02.09 Formulas.md new file mode 100644 index 0000000..f9dd282 --- /dev/null +++ b/docs/02.09 Formulas.md @@ -0,0 +1,34 @@ +# 2.9 Formulas + +Formulas evaluate PHP expressions inside templates. Only a restricted set of PHP functions is allowed. See [[05.01 Appendix A - Allowed PHP functions]]. + +**Syntax** + +```html +(# formula #) +(# formula : number format #) +``` + +Number formatting follows the rules in [[02.08 Data formats]]. + +**Example** + +index.tpl + +```html +{= number: 200.000 =} +{= price: 20.000 =} +{= tax: 0.345 =} + +5 + {$number} = (# 5 + {$number} #) + +Price with tax: $ {$price} + $ {#tax:2.#} = $ (# {$price} + {$tax} :2. #) +``` + +Output + +```html +5 + 200 = 205 + +Price with tax: $20 + $0.35 = $20.35 +``` \ No newline at end of file diff --git a/docs/Features/Lists (loops).md b/docs/02.10 Lists (loops).md similarity index 53% rename from docs/Features/Lists (loops).md rename to docs/02.10 Lists (loops).md index 13ffeb8..344fe7c 100644 --- a/docs/Features/Lists (loops).md +++ b/docs/02.10 Lists (loops).md @@ -1,21 +1,22 @@ -With a list you can repeat some part of template code and work with each item of the list. +# 2.10 Lists (loops) -**Syntax:** +Lists repeat a block of template code for each item in a collection. -``` +**Syntax** +``` [$listvar] - ... some code here ... + ... some code here ... @empty@ - ... some code when the list is empty ... + ... some code when the list is empty ... [/$listvar] ``` -## Breaking a loop +## 6.10.1 Breaking a loop You can stop iteration using `@break@`. Anything after the break tag in the loop body is ignored and the loop stops. -Example: +Example ``` [$products] @@ -24,17 +25,12 @@ Example: [/$products] ``` -**Example:** +**Example** -``` - -echo new div('index.tpl', array( - 'employees' => [ - 'Rafa', - 'Peter', - 'John' - ], - 'products' => [] +```php +echo new div('index.tpl', [ + 'employees' => ['Rafa', 'Peter', 'John'], + 'products' => [] ]); ``` @@ -42,32 +38,32 @@ echo new div('index.tpl', array( ``` Employees: - + [$employees] - {$value} + {$value} [/$employees] - + Products: - + [$products] - {$name} + {$name} @empty@ Empty list of products! [/$employees] ``` -**Output:** +**Output** ``` Employees: - + Rafa Peter John - + Products: - + Empty list of products! ``` -[[Dynamic vars inside a loop]] +Related topic: [[02.11 Dynamic vars inside a loop]]. \ No newline at end of file diff --git a/docs/Features/Dynamic vars inside a loop.md b/docs/02.11 Dynamic vars inside a loop.md similarity index 87% rename from docs/Features/Dynamic vars inside a loop.md rename to docs/02.11 Dynamic vars inside a loop.md index 6a8586e..b3399d6 100644 --- a/docs/Features/Dynamic vars inside a loop.md +++ b/docs/02.11 Dynamic vars inside a loop.md @@ -1,3 +1,7 @@ +# 2.11 Dynamic vars inside a loop + +The following variables are available in loop scope. + |Var|Data type|Description| |---|---|---| |$_item|mixed|Current item| diff --git a/docs/02.12 Iterations.md b/docs/02.12 Iterations.md new file mode 100644 index 0000000..e0b25e0 --- /dev/null +++ b/docs/02.12 Iterations.md @@ -0,0 +1,29 @@ +# 2.12 Iterations + +Iterations generate a numeric loop independent of a data list. The loop variable is exposed as `$value` by default, or by the provided variable name. + +**Syntax** + +``` +[:from,to,var,step:] + ... some code here ... +[/] +``` + +**Example** + +index.tpl + +``` +[:1,10:] {$value} [/] +[:1,10,x:] {$x} [/] +[:1,10,x,2:] {$x} [/] +``` + +Output + +``` +1 2 3 4 5 6 7 8 9 10 +1 2 3 4 5 6 7 8 9 10 +1 3 5 7 9 +``` \ No newline at end of file diff --git a/docs/02.13 Conditional parts.md b/docs/02.13 Conditional parts.md new file mode 100644 index 0000000..a238ec9 --- /dev/null +++ b/docs/02.13 Conditional parts.md @@ -0,0 +1,82 @@ +# 2.13 Conditional parts + +Conditional parts show or hide template fragments based on a boolean variable. The boolean is evaluated by `div::mixedBool`. + +Rules used by `div::mixedBool`: + +1. False if the value is `false`. +2. False if the value is `null`. +3. False if the numeric value is not greater than zero. +4. False if the value is "0". +5. False if the value is an empty string. +6. False if the value is an object without properties. +7. True otherwise. + +Note: the first and last blank space inside conditional blocks are trimmed during parsing. + +**Syntax** + +``` +?$var + ... some code here ... +@else@ + ... some another code here ... +$var? + +!$var + ... some code here ... +@else@ + ... some another code here ... +$var! +``` + +**Example** + +index.php + +```php +echo new div('index.tpl', [ + 'products' => [ + ['name' => 'Banana', 'price' => 20.5], + ['name' => 'Potato', 'price' => 10.8] + ] +]); +``` + +index.tpl + +``` +Products: + +?$products + [$products] + {$name} - {$price} + [/$products] +@else@ + No products +$products? + +Similar result: + +!$products + No products +@else@ + [$products] + {$name} - {$price} + [/$products] +$products! +``` + +Output + +``` +Products: + +Banana - 20.5 +Potato - 10.8 + +Similar result: + +Banana - 20.5 +Potato - 10.8 +``` \ No newline at end of file diff --git a/docs/02.14 Conditions.md b/docs/02.14 Conditions.md new file mode 100644 index 0000000..ae4ee85 --- /dev/null +++ b/docs/02.14 Conditions.md @@ -0,0 +1,74 @@ +# 2.14 Conditions + +Conditions evaluate a full boolean expression rather than a single boolean variable. The expression is interpreted as PHP after template substitution, so the resulting expression must be valid PHP. + +**Syntax** + +``` +{?( ... expression ... )?} + ... some code here ... +@else@ + ... some another code here ... +{/?} +``` + +**Example** + +index.php + +```php +echo new div('index.tpl', [ + 'products' => [ + ['name' => 'Banana', 'price' => 20.5], + ['name' => 'Potato', 'price' => 10.8] + ] +]); +``` + +index.tpl + +``` +{?( {$products} > 0 )?} + There are {$products} products in the warehouse +@else@ + There are not products in the warehouse +{/?} +``` + +Output + +``` +There are 2 products in the warehouse +``` + +**Quoting rule** + +If a variable is compared as a string, wrap the replacement in quotes so the final expression is valid PHP. + +Correct: + +``` +{?( "{$userRole}" === "guest" )?} + {% loginPage %} +@else@ + {% dashboard %} +{/?} +``` + +After substitution: + +``` +"guest" === "guest" +``` + +Incorrect (unquoted value): + +``` +{$userRole} === "guest" +``` + +After substitution: + +``` +guest === "guest" +``` \ No newline at end of file diff --git a/docs/Features/Default replacements.md b/docs/02.15 Default replacements.md similarity index 54% rename from docs/Features/Default replacements.md rename to docs/02.15 Default replacements.md index aee1c18..ac5216f 100644 --- a/docs/Features/Default replacements.md +++ b/docs/02.15 Default replacements.md @@ -1,57 +1,50 @@ -Replace some values for another values. +# 2.15 Default replacements -Syntax in PHP +Default replacements map specific input values to alternative output values. -``` +## 6.15.1 PHP usage + +```php true, - "havemoney" => false + "haveproducts" => true, + "havemoney" => false ]); - ``` index.tpl ``` {@ [false, "NO"] @} - + Have products: {$haveproducts} Have money: {$havemoney} - - ``` Output ``` - Have products: YES Have money: NO - ``` -[[Default replacement for a variable]] \ No newline at end of file +Related topic: [[02.16 Default replacement for a variable]]. \ No newline at end of file diff --git a/docs/02.16 Default replacement for a variable.md b/docs/02.16 Default replacement for a variable.md new file mode 100644 index 0000000..f4c2f69 --- /dev/null +++ b/docs/02.16 Default replacement for a variable.md @@ -0,0 +1,17 @@ +# 2.16 Default replacement for a variable + +Default replacements can be scoped to a specific variable. + +## 6.16.1 PHP usage + +```php + [ + ['[b]', ''], + ['[/b]', ''] + ], + + /* preg_replace */ + 'highlight' => [ + ['/*.*?*/', '$0', true] + ] +]); +``` + +index.tpl + +``` +{= htmlfix: [ + ['',''] + ['',''] +] =} + +{:customtags} +{:htmlfix} + +[b]Hello World[/b] + +{:/htmlfix} +{:/customtags} + +{:highlight} + +/* this is a PHP comment */ + +{:/highlight} +``` + +Output + +``` +Hello World + +/* this is a PHP comment */ +``` \ No newline at end of file diff --git a/docs/02.18 Capsules.md b/docs/02.18 Capsules.md new file mode 100644 index 0000000..aff619f --- /dev/null +++ b/docs/02.18 Capsules.md @@ -0,0 +1,61 @@ +# 2.18 Capsules + +A capsule isolates a portion of a template and rebinds the data scope to a single variable. This reduces repetition and improves readability. + +**Syntax** + +``` +[[varname + ... code using properties of varname ... +varname]] +``` + +**Example** + +index.php + +```php + [ + 'name' => 'Banana', + 'price' => 20.5, + 'tax' => 1.5 + ] +]); +``` + +index.tpl + +``` +Product: + +[[product + Name: {$name} + Price: {$price} + Tax: {$tax} +product]] + +Similar: + + Name: {$product.name} + Price: {$product.price} + Tax: {$product.tax} +``` + +Output + +``` +Product: + + Name: Banana + Price: 20.5 + Tax: 1.5 + +Similar: + + Name: Banana + Price: 20.5 + Tax: 1.5 +``` \ No newline at end of file diff --git a/docs/02.19 Locations.md b/docs/02.19 Locations.md new file mode 100644 index 0000000..9472fc3 --- /dev/null +++ b/docs/02.19 Locations.md @@ -0,0 +1,81 @@ +# 2.19 Locations + +Locations define named insertion points in a template, allowing content to be assembled across different template sections. + +**Syntax** + +Define a location: + +``` +(( location_name )) +``` + +Define content for a location: + +``` +{{location_name + +... some content here ... + +location_name}} +``` + +**Example** + +layout.tpl + +``` + + + +
(( content ))
+ + + +``` + +index.tpl + +``` +{% layout %} + +{{header + This is the header +header}} + +{{footer + This is the footer +footer}} + +{{content + This is the content +content}} + +{{header +
.... more in the header ..... +header}} +``` + +Output + +``` + + + +
This is the content
+ + + +``` + +## 6.19.1 Clearing location tags + +By default Div removes location tags after parsing. You can control this during parse cycles with the setup var `div.clear_locations`. + +Example + +``` +{= div.clear_locations: false =} +``` + +This keeps location tags while composing pre-processed templates; remaining location tags are cleared at the end of the top-level parse. \ No newline at end of file diff --git a/docs/02.20 Friendly tags.md b/docs/02.20 Friendly tags.md new file mode 100644 index 0000000..06bb4a0 --- /dev/null +++ b/docs/02.20 Friendly tags.md @@ -0,0 +1,27 @@ +# 2.20 Friendly tags + +Some IDEs treat Div syntax as invalid HTML. Friendly tags allow you to wrap Div code in HTML comments to avoid false positives in editors. + +**Syntax** + +``` + +``` + +**Example** + +``` +This: + + + Name: {$name} + Price: {$price} + + +Is equal to: + +[$products] + Name: {$name} + Price: {$price} +[/$products] +``` \ No newline at end of file diff --git a/docs/Features/Comments.md b/docs/02.21 Comments.md similarity index 56% rename from docs/Features/Comments.md rename to docs/02.21 Comments.md index 4f5278f..8dc31dd 100644 --- a/docs/Features/Comments.md +++ b/docs/02.21 Comments.md @@ -1,13 +1,15 @@ +# 2.21 Comments + +Comments are removed from the output and are not sent to the browser. + **Syntax** ``` - - ``` @@ -23,7 +25,6 @@ **Output** ``` -

Hello world

Powered by Div -``` +``` \ No newline at end of file diff --git a/docs/02.22 Ignored parts (escaping Div parsing).md b/docs/02.22 Ignored parts (escaping Div parsing).md new file mode 100644 index 0000000..6f1ff9b --- /dev/null +++ b/docs/02.22 Ignored parts (escaping Div parsing).md @@ -0,0 +1,35 @@ +# 2.22 Ignored parts (escaping Div parsing) + +Ignored blocks are passed through unchanged. The parser does not interpret tags inside these blocks. + +**Syntax** + +``` +{ignore} + ... some ignored code here ... +{/ignore} +``` + +**Example** + +index.php + +```php +echo new div('index.tpl', ['name' => "Peter"]); +``` + +index.tpl + +``` +{ignore} + +Name: {$name} + +{/ignore} +``` + +Output + +``` +Name: {$name} +``` \ No newline at end of file diff --git a/docs/Features/Strip or clean the resulting code.md b/docs/02.23 Strip or clean the resulting code.md similarity index 50% rename from docs/Features/Strip or clean the resulting code.md rename to docs/02.23 Strip or clean the resulting code.md index 5f0d071..80794bc 100644 --- a/docs/Features/Strip or clean the resulting code.md +++ b/docs/02.23 Strip or clean the resulting code.md @@ -1,23 +1,23 @@ -Clean the resulting code of the parser, eliminating double spaces, unnecessary new lines, etc. +# 2.23 Strip or clean the resulting code -Syntax in templates +Strip blocks normalize whitespace in the output by removing redundant spaces and newlines. -``` +**Syntax** +``` {strip} - ... some ugly code here ... + ... some code here ... {/strip} - ``` -Example +**Example** index.tpl ``` {strip} Hello Jack, ... - + ...the previous lines are of more. {/strip} ``` @@ -27,4 +27,4 @@ Output ``` Hello Jack, ... ...the previous lines are of more. -``` +``` \ No newline at end of file diff --git a/docs/02.24 HTML to plain text.md b/docs/02.24 HTML to plain text.md new file mode 100644 index 0000000..4f91e91 --- /dev/null +++ b/docs/02.24 HTML to plain text.md @@ -0,0 +1,31 @@ +# 2.24 HTML to plain text + +The `txt` block converts HTML to readable plain text. + +**Syntax** + +``` +{txt} + ... some html code here ... +{/txt} + +{txt} width => + ... some html code here ... +{/txt} +``` + +**Example** + +``` +{txt} + +

Document title

+ +{/txt} +``` + +Output + +``` +Document title +``` \ No newline at end of file diff --git a/docs/Features/Global vars.md b/docs/02.25 Global vars.md similarity index 63% rename from docs/Features/Global vars.md rename to docs/02.25 Global vars.md index a169445..45d2362 100644 --- a/docs/Features/Global vars.md +++ b/docs/02.25 Global vars.md @@ -1,51 +1,46 @@ -The global variables conserve their value and they are independent of the instances of the div class. +# 2.25 Global vars -Syntax in PHP +Global variables persist across div instances. -``` +**Syntax** + +```php 'Peter' + 'name' => 'Peter' ]); - + echo new div('index.tpl', [ - 'name' => 'Jack' + 'name' => 'Jack' ]); - ``` index.tpl ``` - Hello {$name} Today is: {$today} - ``` Output ``` - Hello Peter Today is 2012-08-17 - + Hello Jack Today is 2012-08-17 - -``` - +``` \ No newline at end of file diff --git a/docs/Features/Aggregate functions.md b/docs/02.26 Aggregate functions.md similarity index 50% rename from docs/Features/Aggregate functions.md rename to docs/02.26 Aggregate functions.md index f5eb932..caec45f 100644 --- a/docs/Features/Aggregate functions.md +++ b/docs/02.26 Aggregate functions.md @@ -1,58 +1,56 @@ -The aggregate functions similar to SQL. With this feature you can get some results from list's operations, like as "sum", "average", etc. Think of "aggregate functions" as "list's modifiers", similarly to "variable's modifiers". +# 2.26 Aggregate functions -Syntax in templates +Aggregate functions operate on lists and return summary values, similar to SQL aggregates. -```html +**Syntax** +```html {$function:variable-property} ``` |Aggregate function|Syntax for list of lists/objects|Syntax for array of atomic values|Description| |---|---|---|---| -|min|{$min:list-property}|{$min:arrayname}|Minimum "property"| -|max|{$max:list-property}|{$max:arrayname}|Maximum "property"| -|sum|{$sum:list-property}|{$sum:arrayname}|Sum of "properties"| -|avg|{$avg:list-property}|{$avg:arrayname}|Average of "properties"| -|count|{$list-property}|{$arrayname}|Count of true "properties"| +|min|{$min:list-property}|{$min:arrayname}|Minimum property| +|max|{$max:list-property}|{$max:arrayname}|Maximum property| +|sum|{$sum:list-property}|{$sum:arrayname}|Sum of properties| +|avg|{$avg:list-property}|{$avg:arrayname}|Average of properties| +|count|{$list-property}|{$arrayname}|Count of true properties| -Example +**Example** index.php ```php [ - ['title' => 'Who is online', 'weight' => 0, "show" => true], - ['title' => 'Last comments', 'weight' => 1, "show" => false], - ['title' => 'Forum topics', 'weight' => 2, "show" => true] - ], - 'widths' => [800, 700, 600, 500] + 'blocks' => [ + ['title' => 'Who is online', 'weight' => 0, 'show' => true], + ['title' => 'Last comments', 'weight' => 1, 'show' => false], + ['title' => 'Forum topics', 'weight' => 2, 'show' => true] + ], + 'widths' => [800, 700, 600, 500] ]); - ``` index.tpl ```html - + Minimum weight: {$min:blocks-weight} Maximum weight: {$max:blocks-weight} Weight average: {$avg:blocks-weight} Weight sum: {$sum:blocks-weight} Showed blocks: {$blocks-weight} or {$count:blocks-weight} - + - + Minimum weight: {$min:widths} Maximum weight: {$max:widths} Weight average: {$avg:widths} Weight sum: {$sum:widths} Showed blocks: {$widths} - - ``` Output @@ -63,11 +61,10 @@ Maximum weight: 2 Weight average: 1 Weight sum: 3 Showed blocks: 2 or 2 - + Minimum weight: 500 Maximum weight: 800 Weight average: 650 Weight sum: 2600 Showed blocks: 4 - -``` +``` \ No newline at end of file diff --git a/docs/02.27 Macros.md b/docs/02.27 Macros.md new file mode 100644 index 0000000..44f824d --- /dev/null +++ b/docs/02.27 Macros.md @@ -0,0 +1,88 @@ +# 2.27 Macros + +Macros execute restricted PHP inside templates. They are intended for small, controlled transformations and should not replace application logic. + +**Syntax** + +``` + +``` + +**Example** + +index.php + +```php + ['Banana', 'Potato'] +]); +``` + +index.tpl + +``` +{= text: "hello" =} + +{$text} + + + +{$text} + +Products: + + + +There are {$i} products +``` + +Output + +``` +hello + +HELLO + +Products: + +1 - Banana +2 - Potato + +There are 2 products +``` + +## 6.27.1 Restrictions + +- `$this` and `self` are not allowed. +- Only a restricted set of PHP functions is allowed by default. You can extend this list with `setAllowedFunction`. +- Defining functions or classes is not allowed. +- Including other scripts is not allowed. + +## 6.27.2 Capabilities + +- Create template variables. +- Modify template variables. +- Echo output (avoid creating infinite loops). +- Use the allowed div helper methods as functions. +- If the current class extends div, you can call its methods directly. \ No newline at end of file diff --git a/docs/02.28 Sub-parsers.md b/docs/02.28 Sub-parsers.md new file mode 100644 index 0000000..d2a1c87 --- /dev/null +++ b/docs/02.28 Sub-parsers.md @@ -0,0 +1,107 @@ +# 2.28 Sub-parsers + +Sub-parsers are pre-processors that run before the main parser. They allow the programmer to implement custom transformations over parts of a template. + +Sub-parsers can be implemented as functions, static methods, or instance methods in a class that extends div. For security reasons, sub-parsers must be registered before parsing using `div::setSubParser()`. + +**Syntax** + +``` +{sub-parser-name} + ... code sent to the sub-parser ... +{/sub-parser-name} +``` + +**Example** + +index.php + +```php +'.$code.'

'; + return ""; +} + +class MyPage extends div{ + public function beforeBuild(){ + self::setSubParser('combobox', 'buildCombobox'); + } + + public function buildCombobox($properties){ + $prop = self::jsonDecode('{'.$properties.'}'); + $html = "\n"; + return $html; + } + + public function upperthis($text, &$items){ + $text = trim($text); + if (self::issetVar($text, $items)) { + $items[$text] = strtoupper($items[$text]); + } + } +} + +MyPage::setSubParser('literal'); +MyPage::setSubParser('noparse', 'literal'); +MyPage::setSubParser('body'); + +// Similar static registration +// div::setSubParser('upperthis'); + +echo new MyPage('index.tpl'); +``` + +index.tpl + +``` +{body} + Hello world, this is my first sub-parser +{/body} + +{combobox} + name: 'cboCities', + options: [ + {v: 'NY', c: 'New York'}, + {v: 'PA', c: 'Paris'}, + {v: 'TK', c: 'Tokio'} + ] +{/combobox} + +{upperthis}body{/upperthis} + +{$body} + +{literal} + {$body} +{/literal} +``` + +Output + +``` + + +

+ HELLO WORLD, THIS IS MY FIRST SUB-PARSER +

+ +{$body} +``` + +Related topics: [[02.29 Pre-defined sub-parsers]], [[02.30 Sub-parser's events]]. \ No newline at end of file diff --git a/docs/02.29 Pre-defined sub-parsers.md b/docs/02.29 Pre-defined sub-parsers.md new file mode 100644 index 0000000..6cf9dc0 --- /dev/null +++ b/docs/02.29 Pre-defined sub-parsers.md @@ -0,0 +1,5 @@ +# 2.29 Pre-defined sub-parsers + +Div includes a small set of built-in sub-parsers. The default one is: + +- `{parse} ... {/parse}`: runs a pre-process step by creating a new div instance, similar to loops and capsules. \ No newline at end of file diff --git a/docs/02.30 Sub-parser's events.md b/docs/02.30 Sub-parser's events.md new file mode 100644 index 0000000..abe3c01 --- /dev/null +++ b/docs/02.30 Sub-parser's events.md @@ -0,0 +1,44 @@ +# 2.30 Sub-parser's events + +Sub-parsers can run at different moments in the parse cycle. Available events are `beforeParse`, `afterInclude`, and `afterParse`. + +**Example** + +index.tpl + +``` +{= name: "Peter" =} +{= products: [ + { name: "banana", price: 40 }, + { name: "potato", price: 25 } +] =} + +[$products] + {parse:beforeParse} + Name: {$name} + {/parse:beforeParse} + + Product name: {$name} + + {% other %} +[/$products] +``` + +other.tpl + +``` +{parse:beforeParse} + Other name: {$name} +{/parse:beforeParse} +``` + +Output + +``` +Name: Peter +Product name: banana +Other name: banana +Name: Peter +Product name: potato +Other name: potato +``` \ No newline at end of file diff --git a/docs/02.31 System vars.md b/docs/02.31 System vars.md new file mode 100644 index 0000000..746c64d --- /dev/null +++ b/docs/02.31 System vars.md @@ -0,0 +1,68 @@ +# 2.31 System vars + +System variables are provided by the engine and exposed to templates. + +|System var|Description| +|---|---| +|div.now|Result of `time()`| +|div.post|`$_POST`| +|div.get|`$_GET`| +|div.server|`$_SERVER`| +|div.session|`$_SESSION`| +|div.version|Engine version| +|div.script_name|`$_SERVER['SCRIPT_NAME']`| +|div.ascii|ASCII table (e.g., `{$div.ascii.64}` gives `@`)| + +Only a subset is enabled by default: `div.now`, `div.version`, `div.get`, and `div.post`. + +Enable or disable a system var with `div::enableSystemVar()` and `div::disableSystemVar()`. + +## 6.31.1 Engine setup vars + +The engine also reads setup variables from items or template variables. These are not system vars, but they affect parsing: + +- `div.literals`: list of variable names treated as literal (skip further parsing). You can set it in the template or in PHP. Example: `{= div.literals: ["text1", "text2"] =}`. PHP equivalent: `$tpl->addLiteral(["text1", "text2"]);` +- `div.clear_locations`: boolean flag that controls whether location tags are cleared during parse cycles. If false, locations are kept for further composition (useful with pre-processed templates). At the end of the top-level parse, remaining location tags are cleared. + +**Example** + +index.php + +```php + +``` + +In contrast: + +``` +1. Valid JSON: {= digits: "[[:0,8:]{$value},[/]9]" =} +2. Not parsed +3. digits is string +4. Replacement: {$digits} +``` + +**Syntax** + +``` +{= varname: ... value ... =} + +{= varname: some string here =} + +{= varname: [item1, item2, ...] =} + +{= varname: { + prop1: value1, + prop2: value2 +} =} + +{= var1: value1 =} +{= var2: $var1 =} + +{= sum: ->sum(20,30) =} +``` + +Note: the `$` used inside template variable values (for example `{= var2: $var1 =}`) is a fixed token and is not affected by dialect changes. Changing `DIV_TAG_MODIFIER_SIMPLE` only affects replacements in template output. + +**Example** + +index.php + +```php +echo new div('index.tpl', [ + 'price' => 40 +]); +``` + +index.tpl + +``` +{= price: 20 =} + +Price: {$price} + +{= labels: ['A','B','C','D'] =} + +Labels: [$labels] {$value}!$_is_last, $_is_last! [/$labels] + +{= product: { + name: "Potato", + price: 45 +} =} + +Product: {$product.name} +Product's price: {$product.price} + +{= somestring: Blah blah blah =} + +String: {$somestring} + +{= somevar: $price =} + +Some var: {$somevar} +``` + +Output + +``` +Price: 40 + +Labels: A, B, C, D + +Product's price: Potato + +Price: 45 + +String: Blah blah blah + +Some var: 40 +``` + +## 6.32.1 Protected template variables + +To protect a template variable, prefix it with `*`: + +``` +{= *protectedvar: "protected value" =} +``` + +A protected variable cannot be overwritten later. + +## 6.32.2 Loading external template content into a variable + +``` +{= varname: {% external-template %} =} +``` + +External content is loaded on demand during the first replacement. \ No newline at end of file diff --git a/docs/02.33 Template's properties.md b/docs/02.33 Template's properties.md new file mode 100644 index 0000000..811ffd2 --- /dev/null +++ b/docs/02.33 Template's properties.md @@ -0,0 +1,17 @@ +# 2.33 Template's properties + +Templates can include metadata properties that apply only to the file in which they are defined. + +**Syntax** + +```html +@_property_name = property's value +``` + +Example + +```html +@_DIALECT = smarty.dialect +``` + +Properties are identified by the `@_` prefix. \ No newline at end of file diff --git a/docs/02.34 Template's documentation.md b/docs/02.34 Template's documentation.md new file mode 100644 index 0000000..0cce17c --- /dev/null +++ b/docs/02.34 Template's documentation.md @@ -0,0 +1,63 @@ +# 2.34 Template's documentation + +Div can extract documentation metadata embedded in template comments. Each documentation property starts with `@` and is stored by the parser. There is no fixed property list; you can define your own, but Div provides a default template that expects common fields. + +## 6.34.1 Standard properties + +|Variable/property|Description| +|---|---| +|title|Documentation title. Can be passed via `$items` to `getDocsReadable`.| +|name|Template name| +|description|Single-line description| +|version|Template version| +|author|Author| +|update|Last update date| +|vars|List of template variables in the format: required/optional, type, name, description| +|include|List of included templates (auto-added, but can be overridden)| +|example|Example usage snippet| + +## 6.34.2 Syntax + +```html + +``` + +## 6.34.3 Example + +index.tpl + +```html + +``` + +index.php + +```php +parse(); + +echo $tpl->getDocsReadable(); +``` \ No newline at end of file diff --git a/docs/02.35 Including another templates.md b/docs/02.35 Including another templates.md new file mode 100644 index 0000000..145d29b --- /dev/null +++ b/docs/02.35 Including another templates.md @@ -0,0 +1,39 @@ +# 2.35 Including another templates + +Templates can be split into parts and included from a container template. + +**Syntax** + +``` +{% var with path to the template part %} + +or + +{% path/to/template/part %} +``` + +**Example** + +part.tpl + +``` +Hello world! +``` + +index.tpl + +``` +This is the container template: + +{% part %} +``` + +Output + +``` +This is the container template: + +Hello world! +``` + +Note: a template cannot include itself. \ No newline at end of file diff --git a/docs/02.36 Including pre-processed templates.md b/docs/02.36 Including pre-processed templates.md new file mode 100644 index 0000000..9b54b9e --- /dev/null +++ b/docs/02.36 Including pre-processed templates.md @@ -0,0 +1,63 @@ +# 2.36 Including pre-processed templates + +Pre-processed includes parse the included template before insertion. + +**Syntax** + +``` +{%% var with path to the template part %%} + +or + +{%% path/to/template/part %%} +``` + +**Example** + +index.php + +```php + 'Unnamed', + 'products' => [ + ['name' => 'Banana'], + ['name' => 'Potato'] + ] +]); +``` + +index.tpl + +``` +Include: + +[$products] + {% part %} +[/$products] + +Preprocessed: + +[$products] + {%% part %%} +[/$products] +``` + +part.tpl + +``` +{$name} +``` + +Output + +``` +Banana + +Potato + +Unnamed + +Unnamed +``` \ No newline at end of file diff --git a/docs/Features/Dialects.md b/docs/02.37 Dialects.md similarity index 77% rename from docs/Features/Dialects.md rename to docs/02.37 Dialects.md index 852d3e8..23af9a5 100644 --- a/docs/Features/Dialects.md +++ b/docs/02.37 Dialects.md @@ -1,8 +1,10 @@ -You can change the proposed Div tags for templates. By doing this, you are creating a "dialect" for the template language. The dialects can be very useful when you want to zoom in Div language to a known template language or easier to understand by its developers. It can also be useful when you want to process template contains tags similar to Div. +# 2.37 Dialects -The dialect in Div is defined by a set of constants that begin with the prefix DIV_TAG. A dialect have required tags and rules that are verified. You can use the tool [Div Dialect Creator](http://safe.phpclasses.net/browse/view/html/file/58096/user/rafa3/auth/1476112747-156f9c/name/dialect.html) to create dialects. +Dialects allow you to redefine template tags by overriding constants that start with `DIV_TAG`. This lets you map Div syntax to another template language or avoid collisions with existing markup. -To create a new dialect you should define the constants before including the file **div.php**. You are not forced to define all the constants, so alone those that you need to change. The following table show the set of constants that define a dialect in Div. +Define dialect constants before loading `div.php`. You only need to override the constants you want to change; the rest use defaults. + +The following table lists the dialect constants and their default values. |Constant|Default value| |:--|:--| @@ -49,7 +51,7 @@ To create a new dialect you should define the constants before including the fil |DIV_TAG_SUBPARSER_END_SUFFIX|}| |DIV_TAG_IGNORE_BEGIN|{ignore}| |DIV_TAG_IGNORE_END|{/ignore}| -|DIV_TAG_COMMENT_BEGIN|<\!--{ | +|DIV_TAG_COMMENT_BEGIN|| |DIV_TAG_TXT_BEGIN|{txt}| |DIV_TAG_TXT_END|{/txt}| @@ -97,7 +99,7 @@ To create a new dialect you should define the constants before including the fil |DIV_TAG_MULTI_REPLACEMENT_BEGIN_SUFFIX|}| |DIV_TAG_MULTI_REPLACEMENT_END_PREFIX|{:/| |DIV_TAG_MULTI_REPLACEMENT_END_SUFFIX|}| -|DIV_TAG_FRIENDLY_BEGIN|| |DIV_TAG_AGGREGATE_FUNCTION_COUNT|count| |DIV_TAG_AGGREGATE_FUNCTION_MAX|max| @@ -112,7 +114,7 @@ To create a new dialect you should define the constants before including the fil |DIV_TAG_LOCATION_CONTENT_BEGIN_SUFFIX| | |DIV_TAG_LOCATION_CONTENT_END_PREFIX|| |DIV_TAG_LOCATION_CONTENT_END_SUFFIX|}}| -|DIV_TAG_MACRO_BEGIN|<\? | +|DIV_TAG_MACRO_BEGIN|| |DIV_TAG_SPECIAL_REPLACE_NEW_LINE|{\n}| |DIV_TAG_SPECIAL_REPLACE_CAR_RETURN|{\r}| @@ -120,8 +122,6 @@ To create a new dialect you should define the constants before including the fil |DIV_TAG_SPECIAL_REPLACE_VERTICAL_TAB|{\v}| |DIV_TAG_SPECIAL_REPLACE_NEXT_PAGE|{\f}| |DIV_TAG_SPECIAL_REPLACE_DOLLAR_SYMBOL|{\$}| -|DIV_TAG_TEASER_BREAK|<\!--break--> | -[[Multiple dialects]] -[[Dialect translator]] -[[Understanding the syntax]] +|DIV_TAG_TEASER_BREAK| | +Related topics: [[02.38 Multiple dialects]], [[02.39 Dialect translator]], [[02.01 Understanding the syntax]]. \ No newline at end of file diff --git a/docs/Features/Multiple dialects.md b/docs/02.38 Multiple dialects.md similarity index 56% rename from docs/Features/Multiple dialects.md rename to docs/02.38 Multiple dialects.md index 8960301..aad394b 100644 --- a/docs/Features/Multiple dialects.md +++ b/docs/02.38 Multiple dialects.md @@ -1,6 +1,8 @@ -With the [template's property](https://divengine.org/documentation/div-php-template-engine/features/custom-dialects/multiple-dialects#template-property) @__DIALECT you can specify the dialect for current template source. This dialect should be written in a separeted file with JSON code. For example: +# 2.38 Multiple dialects -Example +You can set a dialect per template using the `@_DIALECT` property. The dialect file contains a JSON object of `DIV_TAG_*` overrides. + +**Example** index.tpl @@ -43,16 +45,16 @@ twig.dialect index.php -``` +```php 'Peter', - 'foo' => [ - 'bar' => 45 - ] + +echo new div("index.tpl", [ + 'name' => 'Peter', + 'foo' => [ + 'bar' => 45 + ] ]); ``` @@ -60,8 +62,8 @@ Output ``` Name: Peter - + {$name} - + 45 -``` +``` \ No newline at end of file diff --git a/docs/02.39 Dialect translator.md b/docs/02.39 Dialect translator.md new file mode 100644 index 0000000..cb0c84b --- /dev/null +++ b/docs/02.39 Dialect translator.md @@ -0,0 +1,46 @@ +# 2.39 Dialect translator + +Div can translate from any dialect to the current dialect. Translation uses the current template variables for context, so you must create a div instance before translating. + +**Example** + +index.php + +```php +translateFrom([ + 'DIV_TAG_IGNORE_BEGIN' => '{literal}', + 'DIV_TAG_IGNORE_END' => '{/literal}' +]); + +$tpl->show(); +``` + +index.tpl + +``` +{= name: "Peter" =} + +{literal} + {$name} +{/literal} + +{$name} +``` + +index.tpl (translated) + +``` +{= name: "Peter" =} + +{ignore} + {$name} +{/ignore} + +{$name} +``` \ No newline at end of file diff --git a/docs/02.40 Custom modifiers.md b/docs/02.40 Custom modifiers.md new file mode 100644 index 0000000..f8d7aca --- /dev/null +++ b/docs/02.40 Custom modifiers.md @@ -0,0 +1,44 @@ +# 2.40 Custom modifiers + +Custom modifiers extend the variable modifier system. A custom modifier can be a function or a static method, and it must accept a single parameter. + +**Example** + +index.php + +```php + 'Hello World']); +``` + +index.tpl + +``` +{upper:text} + +{lower:text} +``` + +Output + +``` +HELLO WORLD + +hello world +``` \ No newline at end of file diff --git a/docs/02.41 Object Oriented Programming.md b/docs/02.41 Object Oriented Programming.md new file mode 100644 index 0000000..85ded88 --- /dev/null +++ b/docs/02.41 Object Oriented Programming.md @@ -0,0 +1,72 @@ +# 2.41 Object Oriented Programming + +Div can be extended through inheritance. The subclass should preserve the parent constructor signature. The recommended extension point is the `beforeBuild()` hook. + +Note: If `$src` is null and `__src` is not set, Div derives the template path from the subclass filename via Reflection (e.g., `MyPage.php` -> `MyPage.tpl`). Pass `$src` explicitly to override this behavior. + +**Example** + +```php + 'Banana', 'price' => 20], + ['name' => 'Potato', 'price' => 30] + ]; + } + + public function sum($x, $y){ + return $x + $y; + } +} +``` + +index.tpl + +``` +{= products: ->getProducts() =} +{= result: ->sum(20,30) =} + +[$products] + {$name} +[/$products] + +{$result} +``` + +Output + +``` +Banana +Potato + +50 +``` + +Note: the `->` operator in template method calls is a fixed token and is not affected by dialect changes. + +Related topics: [[02.44 The __toString magic method]], [[02.42 Content like an object (intelligent data)]]. \ No newline at end of file diff --git a/docs/02.42 Content like an object (intelligent data).md b/docs/02.42 Content like an object (intelligent data).md new file mode 100644 index 0000000..841caf7 --- /dev/null +++ b/docs/02.42 Content like an object (intelligent data).md @@ -0,0 +1,160 @@ +# 2.42 Content like an object (intelligent data) + +Values passed to the div constructor can be objects, arrays, or a mix of both. Templates can access object properties and methods depending on the current scope. + +Internal note: Div merges scope data using a deep-copy helper (historically called `cop`) from `divengine/functions`. This is internal behavior and not part of the public API. + +## 6.42.1 Template scope example + +index.php + +```php +values = $values; + } + + public function implode(){ + return implode(",", $this->values); + } +} + +echo new div('index.tpl', new MyData(["A","B","C","D"])); +``` + +index.tpl + +``` +{= data: ->implode() =} + +{$data} +``` + +Output + +``` +A,B,C,D +``` + +## 6.42.2 Capsule scope example + +index.php + +```php +value = $value; + } + + public function upper(){ + return strtoupper($this->value); + } +} + +echo new div('index.tpl', ['name' => new MyString('peter')]); +``` + +index.tpl + +``` +[[name + {$value} + + {= up: ->upper() =} + + {$up} +name]] +``` + +Output + +``` +peter +PETER +``` + +## 6.42.3 Direct method access (since 4.7) + +index.tpl + +``` +{= up: ->name.upper() =} +{$up} +``` + +Output + +``` +PETER +``` + +## 6.42.4 Loop body scope example + +index.php + +```php +class Person{ + public $first_name; + public $last_name; + + public function __construct($first_name, $last_name){ + $this->first_name = $first_name; + $this->last_name = $last_name; + } + + public function getName(){ + return $this->first_name.' '.$this->last_name; + } +} + +echo new div('index.tpl', [ + 'people' => [ + new Person('John', 'Nash'), + new Person('Albert', 'Einstein'), + new Person('Jacque', 'Fresco') + ] +]); +``` + +index.tpl + +``` +[$people] + {= complete_name: ->getName() =} + + First name: {$first_name} + Last name: {$last_name} + Complete name: {$complete_name} + +[/$people] +``` + +Output + +``` +First name: John +Last name: Nash +Complete name: John Nash + +First name: Albert +Last name: Einstein +Complete name: Albert Einstein + +First name: Jacque +Last name: Fresco +Complete name: Jacque Fresco +``` + +Related topic: [[02.43 Hooks]]. \ No newline at end of file diff --git a/docs/02.43 Hooks.md b/docs/02.43 Hooks.md new file mode 100644 index 0000000..eeb34bb --- /dev/null +++ b/docs/02.43 Hooks.md @@ -0,0 +1,41 @@ +# 2.43 Hooks + +Hooks are methods you can implement in a class that extends div. They are invoked at specific points in the lifecycle. + +Available hooks: + +- `beforeBuild` +- `afterBuild` +- `beforeParse` +- `afterParse` + +The `beforeBuild` hook can modify `$src` and `$items` before parsing begins. + +**Example** + +index.php + +```php +class Page extends div{ + public function beforeBuild(&$src = null, &$items = null){ + $this->title = 'Hello World'; + $items['body'] = 'This is the hook!'; + } +} + +echo new Page('index.tpl'); +``` + +index.tpl + +``` +

{$title}

+

{$body}

+``` + +Output + +``` +

Hello World

+

This is the hook!

+``` \ No newline at end of file diff --git a/docs/02.44 The __toString magic method.md b/docs/02.44 The __toString magic method.md new file mode 100644 index 0000000..d8bd465 --- /dev/null +++ b/docs/02.44 The __toString magic method.md @@ -0,0 +1,126 @@ +# 2.44 The __toString magic method + +If an object implements `__toString`, Div can treat it as a string in three scopes: template scope, loop body scope, and capsule scope. + +- Template scope: `$_to_string` +- Loop and capsule scopes: `$_to_string` and `$value` + +## 6.44.1 Template scope example + +Person.php + +```php +class Person{ + public function __construct($first_name, $last_name){ + $this->first_name = $first_name; + $this->last_name = $last_name; + } + + public function __toString(){ + return $this->first_name . " " . $this->last_name; + } +} +``` + +index.php + +```php +include 'div.php'; +include 'Person.php'; + +echo new div('index.tpl', new Person("Albert", "Einstein")); +``` + +index.tpl + +``` +{$_to_string} +``` + +Output + +``` +Albert Einstein +``` + +## 6.44.2 Loop body scope example + +index.php + +```php + [ + new Person("Albert", "Einstein"), + new Person("John", "Nash") + ] +]); +``` + +index.tpl + +``` +If Person does not have a $value property: + +[$persons] + {$value} +[/$persons] + +You can always use $_to_string: + +[$persons] + {^^^_to_string} +[/$persons] +``` + +Output + +``` +If Person does not have a $value property: + + Albert Einstein + John Nash + +You can always use $_to_string: + + ALBERT EINSTEIN + JOHN NASH +``` + +## 6.44.3 Capsule scope example + +index.php + +```php + new Person("Albert", "Einstein") +]); +``` + +index.tpl + +``` +[[person + {$_to_string} + + {^^^value} + +person]] +``` + +Output + +``` +Albert Einstein + +ALBERT EINSTEIN +``` \ No newline at end of file diff --git a/docs/02.45 Ignore specific variables (the third parameter of constructor).md b/docs/02.45 Ignore specific variables (the third parameter of constructor).md new file mode 100644 index 0000000..9486c90 --- /dev/null +++ b/docs/02.45 Ignore specific variables (the third parameter of constructor).md @@ -0,0 +1,13 @@ +# 2.45 Ignore specific variables (the third parameter of constructor) + +You can tell the engine to ignore certain variables by passing a list of names as the third constructor parameter. + +```php +/* Third parameter as array */ + +echo new div('index.tpl', ['name' => 'Peter'], ['name']); + +/* Third parameter as string */ + +echo new div('index.tpl', ['name' => 'Peter', 'age' => 25, 'sex' => 'M'], 'name,age'); +``` \ No newline at end of file diff --git a/docs/03 PHP Features.md b/docs/03 PHP Features.md new file mode 100644 index 0000000..f659f91 --- /dev/null +++ b/docs/03 PHP Features.md @@ -0,0 +1,171 @@ +# 3. PHP Features + +This section lists the public API for the div class. + +## 3.1 Static methods + +**div::addCustomModifier(**string** $prefix, **string** $function)** + +Register a custom variable modifier. The modifier function must accept a single parameter. + +**div::asThis(**mixed** $mixed)** + +Return a value formatted as HTML for debugging. + +**div::atLeastOneString(**string** $haystack, **array** $needles)** + +Return true if at least one needle is found in the haystack. + +**div::delDefault(**mixed** $search)** + +Remove a default replacement. + +**div::delDefaultByVar(**string** $var, **mixed** $search)** + +Remove a default replacement for a specific variable. + +**div::delGlobal(**string** $var)** + +Remove a global variable. + +**div::disableSystemVar(**string** $var)** + +Disable a system variable for performance. + +**div::enableSystemVar(**string** $var)** + +Enable a system variable. + +**div::error(**string** $errmsg, **string** $level = 'WARNING')** + +Emit an error and stop execution. + +**div::fileExists(**string** $filename)** + +Secure file existence check. + +**div::getLastKeyOfArray(**array** $arr)** + +Return the last key of an array. + +**div::getCountOfParagraphs(**string** $text)** + +Count paragraphs in a string. + +**div::getCountOfSentences(**string** $text)** + +Count sentences in a string. + +**div::getCountOfWords(**string** $text)** + +Count words in a string. + +**div::getDefault(**mixed** $value)** + +Return a default replacement for a value. + +**div::getDefaultByVar(**string** $var, **mixed** $value)** + +Return a default replacement for a value scoped to a variable. + +**div::getSystemData()** + +Return loaded system data. + +**div::getVersion()** + +Return the current engine version string. + +**div::getVarsFromCode(**string** $code)** + +Return the list of variables referenced in PHP code. + +**div::haveVarsThisCode(**string** $code)** + +Return true if PHP code references any variables. + +**div::htmlToText(**string** $html, **integer** $width = 50)** + +Convert HTML to plain text. + +**div::isArrayOfArray(**array** $arr)** + +Return true if the array contains arrays. + +**div::isArrayOfObjects(**array** $arr)** + +Return true if the array contains objects. + +**div::isCli()** + +Return true if the script runs in CLI. + +**div::isNumericList(**array** $arr)** + +Return true if the array is numeric. + +**div::isValidExpression(**string** $code)** + +Validate a PHP expression. + +**div::isDir(**string** $dirname)** + +Secure `is_dir`. + +**div::isString(**mixed** $value)** + +Secure `is_string`. + +**div::jsonDecode(**string** $str)** + +Decode JSON. + +**div::jsonEncode(**mixed** $data)** + +Encode JSON. + +**div::log(**string** $msg, **string** $level = ' ')** + +Write a log message. + +**div::logOn(**string** $logfile)** + +Enable debug logging to a file. + +**div::mixedBool(**mixed** $value)** + +Convert a value to boolean using Div rules. + +**div::setAllowedFunction(**string** $funcname)** + +Allow a PHP function in formulas or macros. + +**div::setDefault(**mixed** $search, **mixed** $replace)** + +Add or update a default replacement. + +**div::setDefaultByVar(**string** $var, **mixed** $search, **mixed** $replace, **bool** $update = true)** + +Add or update a default replacement for a specific variable. + +**div::unsetAllowedFunction(**string** $funcname)** + +Remove a previously allowed function. + +**div::utf162utf8(**string** $utf16)** + +Convert UTF-16 to UTF-8. + +**div::varExists(**string** $var, **mixed** &$items = null)** + +Return true if a variable exists in items (recursive). + +## 3.2 Instance methods + +**div->addLiteral(**string** $var)** + +Mark one or more template variables as literal (skip further parsing). Accepts a space- or comma-separated list. + +**div->getLiterals()** + +Return the current literal vars map for this instance. diff --git a/docs/04 Mechanisms.md b/docs/04 Mechanisms.md new file mode 100644 index 0000000..d3533b1 --- /dev/null +++ b/docs/04 Mechanisms.md @@ -0,0 +1,7 @@ +# 4. Mechanisms + +This chapter describes higher-level mechanisms built from the core template language. + +- [[04.01 Components]] +- [[04.02 Recursion]] +- [[04.03 Templates inheritance]] diff --git a/docs/04.01 Components.md b/docs/04.01 Components.md new file mode 100644 index 0000000..dfaec91 --- /dev/null +++ b/docs/04.01 Components.md @@ -0,0 +1,58 @@ +# 4.1 Components + +Components are reusable template fragments that encapsulate layout logic and can be composed into larger views. + +## 8.1.1 Build a component + +combobox.tpl + +``` + +``` + +This component uses [[02.03 Simple replacements]], [[02.10 Lists (loops)]], and [[04.02 Recursion]]. + +## 8.1.2 Use a component + +index.tpl + +``` +[[_empty + {= id: "products" =} + {= name: "products" =} + {= options: "products" =} + {% combobox %} +_empty]] +``` + +Using a component is equivalent to including a template fragment, often inside a capsule. + +## 8.1.3 Provide data + +index.php + +```php + [ + ['val' => 1, 'text' => 'Banana'], + ['val' => 2, 'text' => 'Potato'], + ['val' => 3, 'text' => 'Apple'] + ] +]); +``` + +Output + +``` + +``` \ No newline at end of file diff --git a/docs/04.02 Recursion.md b/docs/04.02 Recursion.md new file mode 100644 index 0000000..6f6c99e --- /dev/null +++ b/docs/04.02 Recursion.md @@ -0,0 +1,70 @@ +# 4.2 Recursion + +Div repeatedly interprets a template until no more replacements are possible. This is a convergence process, not a recursive algorithm, and it does not use the call stack. + +Example + +index.php + +```php +name = 'Banana'; +$product->price = 20.5; + +echo new div('index.tpl', [ + 'product' => $product, + 'object' => 'product' +]); +``` + +index.tpl (origin) + +``` +[${$object}] + +{$_key} = {$value} + +[/${$object}] +``` + +Step 1 + +``` +[$product] + +{$_key} = {$value} + +[/$product] +``` + +Step 2 + +``` +[$product] + +name = {$value} + +[/$product] +``` + +Step 3 + +``` +[$product] + +name = Banana +price = {$value} + +[/$product] +``` + +Step 4 + +``` +name = Banana +price = 20.5 +``` \ No newline at end of file diff --git a/docs/04.03 Templates inheritance.md b/docs/04.03 Templates inheritance.md new file mode 100644 index 0000000..8ddd31e --- /dev/null +++ b/docs/04.03 Templates inheritance.md @@ -0,0 +1,90 @@ +# 4.3 Templates inheritance + +Div does not implement explicit inheritance, but equivalent behavior can be achieved with existing features. This section outlines three variants. + +## 8.3.1 Variant 1: Switch includes + +Use a variable to select which template to include. + +``` +{% block %} + +// or + +{% {$block} %} +``` + +## 8.3.2 Variant 2: Protected template variables + +The parent template defines a protected variable for a block. The child template overrides it and includes the parent. + +parent.tpl + +``` +... any code ... +{= block1: + +... code of block 1 ... + +=} + +... another code... + +{$block1} +``` + +child.tpl + +``` +{= *block1: + + ... another code for block 1 ... + +=} + +{% parent %} +``` + +## 8.3.3 Variant 3: Locations + +Define locations in the parent and populate them from the child. + +parent.tpl + +``` +... any code ... + +(( block1 )) + +... another code... + +{= parent_block1: + +... code block 1 written by the parent ... + +=} +``` + +child.tpl + +``` +{% parent %} + +{{block1 + {$parent_block1} + +... The child's content ... + +block1}} +``` + +Output + +``` +... any code ... + +... code block 1 written by the parent ... +... The child's content ... + +... another code... +``` \ No newline at end of file diff --git a/docs/05 Appendixes.md b/docs/05 Appendixes.md new file mode 100644 index 0000000..1aee151 --- /dev/null +++ b/docs/05 Appendixes.md @@ -0,0 +1,4 @@ +# 5. Appendixes + +- [[05.01 Appendix A - Allowed PHP functions]] +- [[05.02 Appendix B - Comparison of syntax of Smarty and Div]] diff --git a/docs/Appendixes/Appendix A - Allowed PHP functions.md b/docs/05.01 Appendix A - Allowed PHP functions.md similarity index 60% rename from docs/Appendixes/Appendix A - Allowed PHP functions.md rename to docs/05.01 Appendix A - Allowed PHP functions.md index bb42a0d..22968c1 100644 --- a/docs/Appendixes/Appendix A - Allowed PHP functions.md +++ b/docs/05.01 Appendix A - Allowed PHP functions.md @@ -1,4 +1,6 @@ -These are the PHP functions that can be used in [conditions](https://divengine.org/documentation/div-php-template-engine/appendixes/appendix-allowed-php-functions#conditions), [formulas](https://divengine.org/documentation/div-php-template-engine/appendixes/appendix-allowed-php-functions#formulas) and another expressions in the templates: +# 5.1 Appendix A - Allowed PHP functions + +The following PHP functions can be used in conditions, formulas, and other expressions. | | | | |---|---|---| @@ -40,30 +42,32 @@ These are the PHP functions that can be used in [conditions](https://divengine. |[ltrim](http://www.php.net/manual/en/function.ltrim.php)|[max](http://www.php.net/manual/en/function.max.php)|[md5](http://www.php.net/manual/en/function.md5.php)| |[metaphone](http://www.php.net/manual/en/function.metaphone.php)|[microtime](http://www.php.net/manual/en/function.microtime.php)|[min](http://www.php.net/manual/en/function.min.php)| |[mktime](http://www.php.net/manual/en/function.mktime.php)|[money_format](http://www.php.net/manual/en/function.money_format.php)|[mt_getrandmax](http://www.php.net/manual/en/function.mt_getrandmax.php)| -|[mt_rand](http://www.php.net/manual/en/function.mt_rand.php)|[mt_srand](http://www.php.net/manual/en/function.mt_srand.php)|[nl2br](http://www.php.net/manual/en/function.nl2br.php)| -|[nl_langinfo](http://www.php.net/manual/en/function.nl_langinfo.php)|[number_format](http://www.php.net/manual/en/function.number_format.php)|[octdec](http://www.php.net/manual/en/function.octdec.php)| -|[ord](http://www.php.net/manual/en/function.ord.php)|[pi](http://www.php.net/manual/en/function.pi.php)|[pow](http://www.php.net/manual/en/function.pow.php)| -|[quoted_printable_decode](http://www.php.net/manual/en/function.quoted_printable_decode.php)|[quoted_printable_encode](http://www.php.net/manual/en/function.quoted_printable_encode.php)|[quotemeta](http://www.php.net/manual/en/function.quotemeta.php)| -|[rad2deg](http://www.php.net/manual/en/function.rad2deg.php)|[rand](http://www.php.net/manual/en/function.rand.php)|[rand](http://www.php.net/manual/en/function.rand.php)| -|[round](http://www.php.net/manual/en/function.round.php)|[rtrim](http://www.php.net/manual/en/function.rtrim.php)|[sha1](http://www.php.net/manual/en/function.sha1.php)| -|[similar_text](http://www.php.net/manual/en/function.similar_text.php)|[sin](http://www.php.net/manual/en/function.sin.php)|[sinh](http://www.php.net/manual/en/function.sinh.php)| -|[sizeof](http://www.php.net/manual/en/function.sizeof.php)|[soundex](http://www.php.net/manual/en/function.soundex.php)|[sprintf](http://www.php.net/manual/en/function.sprintf.php)| -|[sprintf](http://www.php.net/manual/en/function.sprintf.php)|[sqrt](http://www.php.net/manual/en/function.sqrt.php)|[srand](http://www.php.net/manual/en/function.srand.php)| -|[str_ireplace](http://www.php.net/manual/en/function.str_ireplace.php)|[str_pad](http://www.php.net/manual/en/function.str_pad.php)|[str_repeat](http://www.php.net/manual/en/function.str_repeat.php)| -|[str_replace](http://www.php.net/manual/en/function.str_replace.php)|[str_rot13](http://www.php.net/manual/en/function.str_rot13.php)|[str_shuffle](http://www.php.net/manual/en/function.str_shuffle.php)| -|[strcasecmp](http://www.php.net/manual/en/function.strcasecmp.php)|[strchr](http://www.php.net/manual/en/function.strchr.php)|[strcmp](http://www.php.net/manual/en/function.strcmp.php)| -|[strcoll](http://www.php.net/manual/en/function.strcoll.php)|[strcspn](http://www.php.net/manual/en/function.strcspn.php)|[strftime](http://www.php.net/manual/en/function.strftime.php)| -|[strip_tags](http://www.php.net/manual/en/function.strip_tags.php)|[stripcslashes](http://www.php.net/manual/en/function.stripcslashes.php)|[stripos](http://www.php.net/manual/en/function.stripos.php)| -|[stripslashes](http://www.php.net/manual/en/function.stripslashes.php)|[stristr](http://www.php.net/manual/en/function.stristr.php)|[strlen](http://www.php.net/manual/en/function.strlen.php)| -|[strnatcasecmp](http://www.php.net/manual/en/function.strnatcasecmp.php)|[strnatcmp](http://www.php.net/manual/en/function.strnatcmp.php)|[strncasecmp](http://www.php.net/manual/en/function.strncasecmp.php)| -|[strncmp](http://www.php.net/manual/en/function.strncmp.php)|[strpbrk](http://www.php.net/manual/en/function.strpbrk.php)|[strpos](http://www.php.net/manual/en/function.strpos.php)| -|[strptime](http://www.php.net/manual/en/function.strptime.php)|[strrchr](http://www.php.net/manual/en/function.strrchr.php)|[strrev](http://www.php.net/manual/en/function.strrev.php)| -|[strripos](http://www.php.net/manual/en/function.strripos.php)|[strrpos](http://www.php.net/manual/en/function.strrpos.php)|[strspn](http://www.php.net/manual/en/function.strspn.php)| -|[strtolower](http://www.php.net/manual/en/function.strtolower.php)|[strtotime](http://www.php.net/manual/en/function.strtotime.php)|[strtotime](http://www.php.net/manual/en/function.strtotime.php)| -|[strtoupper](http://www.php.net/manual/en/function.strtoupper.php)|[strtr](http://www.php.net/manual/en/function.strtr.php)|[strtr](http://www.php.net/manual/en/function.strtr.php)| +|[mt_rand](http://www.php.net/manual/en/function.mt_rand.php)|[mt_srand](http://www.php.net/manual/en/function.mt_srand.php)| +|[nl2br](http://www.php.net/manual/en/function.nl2br.php)|[nl_langinfo](http://www.php.net/manual/en/function.nl_langinfo.php)|[number_format](http://www.php.net/manual/en/function.number_format.php)| +|[octdec](http://www.php.net/manual/en/function.octdec.php)|[ord](http://www.php.net/manual/en/function.ord.php)|[pi](http://www.php.net/manual/en/function.pi.php)| +|[pow](http://www.php.net/manual/en/function.pow.php)|[quoted_printable_decode](http://www.php.net/manual/en/function.quoted_printable_decode.php)|[quoted_printable_encode](http://www.php.net/manual/en/function.quoted_printable_encode.php)| +|[quotemeta](http://www.php.net/manual/en/function.quotemeta.php)|[rad2deg](http://www.php.net/manual/en/function.rad2deg.php)|[rand](http://www.php.net/manual/en/function.rand.php)| +|[rand](http://www.php.net/manual/en/function.rand.php)|[round](http://www.php.net/manual/en/function.round.php)|[rtrim](http://www.php.net/manual/en/function.rtrim.php)| +|[sha1](http://www.php.net/manual/en/function.sha1.php)|[similar_text](http://www.php.net/manual/en/function.similar_text.php)|[sin](http://www.php.net/manual/en/function.sin.php)| +|[sinh](http://www.php.net/manual/en/function.sinh.php)|[sizeof](http://www.php.net/manual/en/function.sizeof.php)|[soundex](http://www.php.net/manual/en/function.soundex.php)| +|[sprintf](http://www.php.net/manual/en/function.sprintf.php)|[sprintf](http://www.php.net/manual/en/function.sprintf.php)|[sqrt](http://www.php.net/manual/en/function.sqrt.php)| +|[srand](http://www.php.net/manual/en/function.srand.php)|[str_ireplace](http://www.php.net/manual/en/function.str_ireplace.php)|[str_pad](http://www.php.net/manual/en/function.str_pad.php)| +|[str_repeat](http://www.php.net/manual/en/function.str_repeat.php)|[str_replace](http://www.php.net/manual/en/function.str_replace.php)|[str_rot13](http://www.php.net/manual/en/function.str_rot13.php)| +|[str_shuffle](http://www.php.net/manual/en/function.str_shuffle.php)|[strcasecmp](http://www.php.net/manual/en/function.strcasecmp.php)|[strchr](http://www.php.net/manual/en/function.strchr.php)| +|[strcmp](http://www.php.net/manual/en/function.strcmp.php)|[strcoll](http://www.php.net/manual/en/function.strcoll.php)|[strcspn](http://www.php.net/manual/en/function.strcspn.php)| +|[strftime](http://www.php.net/manual/en/function.strftime.php)|[strip_tags](http://www.php.net/manual/en/function.strip_tags.php)|[stripcslashes](http://www.php.net/manual/en/function.stripcslashes.php)| +|[stripos](http://www.php.net/manual/en/function.stripos.php)|[stripslashes](http://www.php.net/manual/en/function.stripslashes.php)|[stristr](http://www.php.net/manual/en/function.stristr.php)| +|[strlen](http://www.php.net/manual/en/function.strlen.php)|[strnatcasecmp](http://www.php.net/manual/en/function.strnatcasecmp.php)|[strnatcmp](http://www.php.net/manual/en/function.strnatcmp.php)| +|[strncasecmp](http://www.php.net/manual/en/function.strncasecmp.php)|[strncmp](http://www.php.net/manual/en/function.strncmp.php)|[strpbrk](http://www.php.net/manual/en/function.strpbrk.php)| +|[strpos](http://www.php.net/manual/en/function.strpos.php)|[strptime](http://www.php.net/manual/en/function.strptime.php)|[strrchr](http://www.php.net/manual/en/function.strrchr.php)| +|[strrev](http://www.php.net/manual/en/function.strrev.php)|[strripos](http://www.php.net/manual/en/function.strripos.php)|[strrpos](http://www.php.net/manual/en/function.strrpos.php)| +|[strspn](http://www.php.net/manual/en/function.strspn.php)|[strtolower](http://www.php.net/manual/en/function.strtolower.php)|[strtotime](http://www.php.net/manual/en/function.strtotime.php)| +|[strtotime](http://www.php.net/manual/en/function.strtotime.php)|[strtoupper](http://www.php.net/manual/en/function.strtoupper.php)|[strtr](http://www.php.net/manual/en/function.strtr.php)| +|[strtr](http://www.php.net/manual/en/function.strtr.php)| |[strval](http://www.php.net/manual/en/function.strval.php)|[substr](http://www.php.net/manual/en/function.substr.php)|[substr_compare](http://www.php.net/manual/en/function.substr_compare.php)| -|[substr_count](http://www.php.net/manual/en/function.substr_count.php)|[substr_replace](http://www.php.net/manual/en/function.substr_replace.php)|[tan](http://www.php.net/manual/en/function.tan.php)| -|[tanh](http://www.php.net/manual/en/function.tanh.php)|[time](http://www.php.net/manual/en/function.time.php)|[timezone_name_from_abbr](http://www.php.net/manual/en/function.timezone_name_from_abbr.php)| -|[timezone_version_get](http://www.php.net/manual/en/function.timezone_version_get.php)|[trim](http://www.php.net/manual/en/function.trim.php)|[ucfirst](http://www.php.net/manual/en/function.ucfirst.php)| -|[ucwords](http://www.php.net/manual/en/function.ucwords.php)|[uniqid](http://www.php.net/manual/en/function.uniqid.php)|[unixtojd](http://www.php.net/manual/en/function.unixtojd.php)| -|[urldecode](http://www.php.net/manual/en/function.urldecode.php)|[urlencode](http://www.php.net/manual/en/function.urlencode.php)|[wordwrap](http://www.php.net/manual/en/function.wordwrap.php)| \ No newline at end of file +|[substr_count](http://www.php.net/manual/en/function.substr_count.php)|[substr_replace](http://www.php.net/manual/en/function.substr_replace.php)| +|[tan](http://www.php.net/manual/en/function.tan.php)|[tanh](http://www.php.net/manual/en/function.tanh.php)|[time](http://www.php.net/manual/en/function.time.php)| +|[timezone_name_from_abbr](http://www.php.net/manual/en/function.timezone_name_from_abbr.php)|[timezone_version_get](http://www.php.net/manual/en/function.timezone_version_get.php)|[trim](http://www.php.net/manual/en/function.trim.php)| +|[ucfirst](http://www.php.net/manual/en/function.ucfirst.php)|[ucwords](http://www.php.net/manual/en/function.ucwords.php)|[uniqid](http://www.php.net/manual/en/function.uniqid.php)| +|[unixtojd](http://www.php.net/manual/en/function.unixtojd.php)|[urldecode](http://www.php.net/manual/en/function.urldecode.php)|[urlencode](http://www.php.net/manual/en/function.urlencode.php)| +|[wordwrap](http://www.php.net/manual/en/function.wordwrap.php)| \ No newline at end of file diff --git a/docs/05.02 Appendix B - Comparison of syntax of Smarty and Div.md b/docs/05.02 Appendix B - Comparison of syntax of Smarty and Div.md new file mode 100644 index 0000000..90c1703 --- /dev/null +++ b/docs/05.02 Appendix B - Comparison of syntax of Smarty and Div.md @@ -0,0 +1,61 @@ +# 5.2 Appendix B - Comparison of syntax of Smarty and Div + +This appendix compares equivalent syntax in Smarty and Div. + +## 11.2.1 Loops + +Smarty: + +```html +{foreach $foo as $bar} + {$bar.zag} + {$bar.zag2} + {$bar.zag3} + {foreachelse} + There were no rows found +{/foreach} +``` + +Div: + +```html +[$foo] + {$zag} + {$zag2} + {$zag3} +@empty@ + There were no rows found +[/$foo] +``` + +## 11.2.2 Include + +Smarty: + +```html +{include file="header.tpl"} +``` + +Div: + +```html +{% header %} +``` + +## 11.2.3 Iterations + +Smarty: + +```html +{for $x = 1 to 20 step 2} + {$x} +{/for} +``` + +Div: + +```html +[:1,20,x,2:] + {$x} +[/] +``` \ No newline at end of file diff --git a/docs/Appendixes.md b/docs/Appendixes.md deleted file mode 100644 index bc93228..0000000 --- a/docs/Appendixes.md +++ /dev/null @@ -1,2 +0,0 @@ -[[Appendix A - Allowed PHP functions]] -[[Appendix B - Comparison of syntax of Smarty and Div]] diff --git a/docs/Appendixes/Appendix B - Comparison of syntax of Smarty and Div.md b/docs/Appendixes/Appendix B - Comparison of syntax of Smarty and Div.md deleted file mode 100644 index b12e47d..0000000 --- a/docs/Appendixes/Appendix B - Comparison of syntax of Smarty and Div.md +++ /dev/null @@ -1,58 +0,0 @@ -### Loops - -Smarty: - -```html -{foreach $foo as $bar} - {$bar.zag} - {$bar.zag2} - {$bar.zag3} - {foreachelse} - There were no rows found -{/foreach} -``` - -Div: - -```html -[$foo] - {$zag} - {$zag2} - {$zag3} -@empty@ - There were no rows found -[/$foo] -``` - -### Include - -Smarty: - -```html -{include file="header.tpl"} -``` - -Div: - -```html -(% header %} -``` - -### Iterations - -Smarty: - -```html -{for $x = 1 to 20 step 2} - {$x} -{/for} -``` - -Div: - -```html -[:1,20,x,2:] - {$x} -[/] -``` - diff --git a/docs/Div PHP Template Engine.md b/docs/Div PHP Template Engine.md deleted file mode 100644 index b4abcc3..0000000 --- a/docs/Div PHP Template Engine.md +++ /dev/null @@ -1,41 +0,0 @@ - -**div** is a [template engine](https://en.wikipedia.org/wiki/Template_processor) and [code generator tool](https://en.wikipedia.org/wiki/Code_generation_%28compiler%29) tool written in [PHP](http://php.net/) and developed since 2011, designed to optimize collaboration between developers and designers through generative programming, model-driven architecture, and meta-programming. This engine not only facilitates the separation of labor between roles but also allows for deep customization through the creation of tailored template [dialects](https://dialector.divengine.org) to meet specific project needs. - -One of the most distinctive features of **div** is its ability to **recursively process templates until there is no more code to process**, effectively avoiding infinite loops and enabling complex, multi-step transformations. This translates into exceptional flexibility for dynamically generating content or code based on the data and logic specified in the templates. - -Additionally, **div** supports the creation of custom template dialects, allowing users to define and modify the syntax to better suit different programming environments or to enhance code readability and maintenance. For example, it's possible to configure a dialect that ensures templates remain as valid XML, facilitating integration with other systems and technologies that utilize XML. - -This engine is the cornerstone of [Divengine Software Solutions](https://divengine.com) and adheres to the philosophy of *"build more with less"* and *"divide the problem, not the people."* **div** proposes code generation based on templates that adhere to clear rules: the model contains all information about what is to be accomplished; the templates define the expected outcomes; and the engine, acting as a black box, takes care of the execution. - -Basic operations include: - -- **Compile**: Combine a template with models and save the result. -- **Transform**: Convert one model to another, reusing the compile operation. -- **Compose**: Integrate different results using the engine and other tools. - -With **div**, developers and designers can avoid repetitive tasks, scale projects based on models, migrate projects to different technologies, and expand applications to other platforms and devices, all while improving application performance and enabling non-technical people to participate in the project's development. -## Install - -```bash -composer require divengine/div -``` -## Upgrade - -```bash -composer upgrade -``` - -[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=divengine&repo=div&show_owner=true&rand=23)](https://github.com/anuraghazra/github-readme-stats) - -[[Introduction to Div PHP Template Engine]] -[[The div class]] -[[The best practices]] -[[Template Engine Features]] -[[Method's reference]] -[[Mechanisms]] -[[Appendixes]] - -Se also the [[CHANGELOG]] and the [[FUTURE]] or this project. - - -#templates diff --git a/docs/FUTURE.md b/docs/FUTURE.md deleted file mode 100644 index 3d637d6..0000000 --- a/docs/FUTURE.md +++ /dev/null @@ -1,44 +0,0 @@ -# FUTURE FEATURES - -## 2016-11-16 -### variable modifier for trim values -###### in the present: - -``` -{strip}{$varname}{/strip} -(# trim("{$varname}") #) -``` - -###### in the future: -``` -ltrim: {-varnme} -rtrim: {varname-} -trim: {-varname-} -trim: {trim:varname} -trim: {$varname:trim} -``` -### variable modifier for var_export -###### in the present: -``` -// create subparser -function export($src, $items){ - $v = $items[$src]; - if (is_object($v)) - $v = get_object_vars($v); - return str_replace("\n","",var_export($v, true)); -} - -div::setSubParser('export'); -``` - -``` -{export}varname{/export} -``` -### bug? subparser before conditional parts - -## 2016-11-21 -### new dialect's components (constants) - -* DIV_TAG_LOOP_ORDER for '_order' var in loops -* DIV_TAG_LOOP_INDEX for '_index' var in loops -* DIV_TAG_LOOP_KEY for '_key' var in loops diff --git a/docs/Features/Capsules.md b/docs/Features/Capsules.md deleted file mode 100644 index 06392d1..0000000 --- a/docs/Features/Capsules.md +++ /dev/null @@ -1,64 +0,0 @@ -An capsule is a part of template for reduce their code, make the template more readable, among other advantages. - -Syntax in templates - -``` - -[[varname - ... In this section you can use the properties of variable if it is - an object or their keys if it is an array ... -varname]] - -``` - -Example - -index.php - -``` - [ - 'name' => 'Banana', - 'price' => 20.5, - 'tax' => 1.5 - ] -]); - -``` - -index.tpl - -``` -Product: - -[[product - Name: {$name} - Price: {$price} - Tax: {$tax} -product]] - -Similar: - - Name: {$product.name} - Price: {$product.price} - Tax: {$product.tax} -``` - -Output - -``` -Product: - - Name: Banana - Price: 20.5 - Tax: 1.5 - -Similar: - - Name: Banana - Price: 20.5 - Tax: 1.5 - -``` diff --git a/docs/Features/Conditional parts.md b/docs/Features/Conditional parts.md deleted file mode 100644 index a6e090d..0000000 --- a/docs/Features/Conditional parts.md +++ /dev/null @@ -1,100 +0,0 @@ -One of the most commonly used functions in the GUI is to show or hide part of the interface. This is achieved with Div in various ways, and one of them is the use of the conditional parts. - -Some conditional on the template is defined by a block that begins and ends with the character question tag (?) or exclamation (!) otherwise, accompanied by a variable that must be a boolean value. For example, you can do this in the template: - -``` -?$showproducts - ... some template here ... -$showproducts? -``` - -If the value of "showproducts" is true, it shows the code between both tags. If the value is false or if you not pass the variable "showproducts", that part of code will be hidden. - -In general, the boolean value is defined by the method **div::mixedBool**, which takes into account the following criteria: - -1. False if the value is false -2. False if the value is null -3. False if the value is not greater than zero -4. False if is "0" -5. False if is an empty string -6. False if is an object without properties -7. The same value in any other case - -Note: the first and last blank space inside conditional blocks are trimmed during parsing. - -Syntax: - -``` - -For test the var as TRUE: - -?$var - ... some code here ... -@else@ - ... some another code here -$var? - -For test the var as FALSE: - -!$var - ... some code here ... -@else@ - ... some another code here -$var! - -``` - -Example: - -index.php - -``` - -echo new div('index.tpl', [ - 'products' => [ - ['name' => 'Banana', 'price' => 20.5], - ['name' => 'Potato', 'price' => 10.8] - ] -]); -``` - -index.tpl - -``` - -Products: - -?$products - [$products] - {$name} - {$price} - [/$products] -@else@ - No products -$products? - -Similar result: - -!$products - No products -@else@ - [$products] - {$name} - {$price} - [/$products] -$products! - -``` - -Output - -``` -Products: - -Banana - 20.5 -Potato - 10.8 - -Similar result: - -Banana - 20.5 -Potato - 10.8 -``` - diff --git a/docs/Features/Conditions.md b/docs/Features/Conditions.md deleted file mode 100644 index 5d505f1..0000000 --- a/docs/Features/Conditions.md +++ /dev/null @@ -1,83 +0,0 @@ -The **conditions** is more complicated than [conditional parts](https://divengine.org/documentation/div-php-template-engine/features/conditions#conditional-parts). With conditions, you can show conditional parts based on a boolean expression and not only from a boolean value. See the [allowed PHP functions](https://divengine.org/documentation/div-php-template-engine/features/conditions#allowed-php-functions). The expression can be an expression of PHP, blended with code of Div. - -Syntax:  - -``` -{?( ... expression ... )?} - - ... some code here ... - -@else@ - - ... some another code here ... - -{/?} -``` - -Example - -index.php - -``` - -echo new div('index.tpl', [ - 'products' => [ - ['name' => 'Banana', 'price' => 20.5], - ['name' => 'Potato', 'price' => 10.8] - ] -]); -``` - -index.tpl - -``` - -{?( {$products} > 0 )?} - There are {$products} products in the warehouse -@else@ - There are not products in the warehouse -{/?} -``` - -Output - -``` - -There are 2 products in the warehouse - -``` - -You must understand that the expression in parentheses will be interpreted by the template engine as well. That means the end result of that interpretation must be a valid PHP boolean expression. An example to understand this is when comparing to strings. - -``` -{?( "{$userRole}" === "guest" )?} -        {% loginPage %} -@else@ -        {% dashboard %} -{/?} -``` - -Notice carefully how the $userRole variable substitution is enclosed in quotes. - -``` -"{$userRole}" === "guest" -``` - -This means that when it is substituted for its value, the value will be enclosed in quotes, because you have told the template engine so. - -``` -"guest" === "guest" -``` - -The following would be an error, because the content of the variable would not be enclosed in quotes and would not result in a valid expression for PHP. - -``` -{$userRole} === "guest" -``` - -Output: - -``` -guest === "guest" -``` - diff --git a/docs/Features/Content like an object (intelligent data).md b/docs/Features/Content like an object (intelligent data).md deleted file mode 100644 index 2cc6739..0000000 --- a/docs/Features/Content like an object (intelligent data).md +++ /dev/null @@ -1,183 +0,0 @@ -The information or content that it is passed to the constructor of the div class, can be an object and/or it can contain objects and you can access to the methods of these objects. The access to those methods to obtain information depends on the context or scope in which is you working. - -Internal note: Div merges scope data using a deep-copy helper (historically called `cop`) from `divengine/functions`. This is internal behavior and not part of the public API. - -Example: "template scope" - -index.php - -``` -values = $values; - } - - public function implode(){ - return implode(",",$this->values); - } - -} - -echo new div('index.tpl', new MyData(["A","B","C","D"])); -``` - -index.tpl - -``` - -{= data: ->implode() =} - -{$data} - -``` - -Output - -``` - -A,B,C,D - -``` - -Example: "capsule scope" - -index.php - -``` -value = $value; - } - - public function upper(){ - return strtoupper($this->value); - } - -} - -// using the class - -echo new div('index.tpl', array('name' => new MyString('peter'))); - -``` - -index.tpl - -``` - -[[name - {$value} - - {= up: ->upper() =} - - {$up} -name]] -``` - -Output - -``` - -peter -PETER - -``` - -#### Example: accesing to any var/object method (new from 4.7) - -**index.tpl** - -``` - -{= up: ->name.upper() =} -{$up} - -``` - -Output - -``` - -PETER -``` - -#### Example: "loop's body scope" - -index.php - -``` -class Person{ - - var $first_name; - var $last_name; - - function __construct($first_name, $last_name){ - $this->first_name = $first_name; - $this->last_name = $last_name; - } - - public function getName(){ - return $this->first_name.' '.$this->last_name; - } - -} - -echo new div('index.tpl', [ - 'people' => [ - new Person('John', 'Nash'), - new Person('Albert', 'Einstein'), - new Person('Jacque', 'Fresco') - ] -]); -``` - -index.tpl - -``` - -[$people] - {= complete_name: ->getName() =} - - First name: {$first_name} - Last name: {$last_name} - Complete name: {$complete_name} - -[/$people] - -``` - -Output - -``` - -First name: John -Last name: Nash -Complete name: John Nash - -First name: Albert -Last name: Einstein -Complete name: Albert Einstein - -First name: Jacque -Last name: Fresco -Complete name: Jacque Fresco - -``` - -[[Hooks]] diff --git a/docs/Features/Custom modifiers.md b/docs/Features/Custom modifiers.md deleted file mode 100644 index 7d51efe..0000000 --- a/docs/Features/Custom modifiers.md +++ /dev/null @@ -1,45 +0,0 @@ -The programmers can create new modifiers of variables. For this the programmers should use the static method "addCustomModifier." The modifier can be a function or a static method of class. The modifier function should have a single parameter. - -**Example:** - -index.php - -``` - 'Hello World')); -``` - -index.tpl - -``` -{upper:text} - -{lower:text} -``` - -Output: - -``` -HELLO WORLD - -hello world -``` diff --git a/docs/Features/Default replacement for a variable.md b/docs/Features/Default replacement for a variable.md deleted file mode 100644 index 6537a28..0000000 --- a/docs/Features/Default replacement for a variable.md +++ /dev/null @@ -1,18 +0,0 @@ -How to define a default replacement for a specific variable? It is really simple: - -Syntax in PHP - -``` -translateFrom([ - 'DIV_TAG_IGNORE_BEGIN' => '{literal}', - 'DIV_TAG_IGNORE_END' => '{/literal}' -]); - -$tpl->show(); -``` - -index.tpl - -``` - -{= name: "Peter" =} - -{literal} - {$name} -{/literal} - -{$name} - -``` - -index.tpl (translated) - -``` - -{= name: "Peter" =} - -{ignore} - {$name} -{/ignore} - -{$name} -``` diff --git a/docs/Features/Formulas.md b/docs/Features/Formulas.md deleted file mode 100644 index 50a7877..0000000 --- a/docs/Features/Formulas.md +++ /dev/null @@ -1,40 +0,0 @@ -To make calculations and other advantages. The formula is a valid PHP expression. See the [[Appendix A - Allowed PHP functions]] - -**Syntax in templates** -     - -```html -(# formula #) -     -OR -     -(# formula : number format #) -``` - -    -The number format are explained in Data formats. - -**Example** - -index.tpl -     - -```html -{= number: 200.000 =} -{=  price:  20.000 =} -{=    tax:   0.345 =} -     -5 + {$number} = (# 5 + {$number} #) -     -Price with tax: ${$price} + ${#tax:2.#} = $(# {$price} + {$tax} :2. #) -``` - -     -Output - -```html -5 + 200 = 205 -     -Price with tax: $20 + $0.35 = $20.35 -``` - diff --git a/docs/Features/Friendly tags.md b/docs/Features/Friendly tags.md deleted file mode 100644 index a377854..0000000 --- a/docs/Features/Friendly tags.md +++ /dev/null @@ -1,31 +0,0 @@ -IDE sometimes detects the code of Div in HTML templates like a syntax error, because they don't have a plugin that identify the syntax of Div. Then, to avoid that it is shown as an error, Div provides two tags to encapsulate its code making it a comment. - -Syntax in templates - -``` - - - -``` - -Example - -index.tpl - -``` - -This: - - - Name: {$name} - Price: {$price} - - -Is equal to: - -[$products] - Name: {$name} - Price: {$price} -[/$products] - -``` diff --git a/docs/Features/HTML to plain text.md b/docs/Features/HTML to plain text.md deleted file mode 100644 index 30ec079..0000000 --- a/docs/Features/HTML to plain text.md +++ /dev/null @@ -1,28 +0,0 @@ -Syntax: - -``` -{txt} - ... some html code here ... -{/txt} - -{txt} width => - ... some html code here ... -{/txt} -``` - -Example - -``` -{txt} - -

Document title

- -{/txt} -``` - -Output: - -``` -Document title -``` - diff --git a/docs/Features/Hooks.md b/docs/Features/Hooks.md deleted file mode 100644 index b6780b9..0000000 --- a/docs/Features/Hooks.md +++ /dev/null @@ -1,40 +0,0 @@ -The hooks are methods that can be implemented by the programmer in a class that inherit from div. This methods will be executed by div in some events. For example, before or after parse of template. - -At the moment, the hooks are **beforeBuild**, **afterBuild**, **beforeParse** and **afterParse**. In the **beforeBuild** hook, you can modify the **$src** and **$items** optional parameters of the div constructor. - -Example: - -index.php - -``` - -class Page extends div{ - - public function beforeBuild(&$src = null, &$items = null){ - $this->title = 'Hello World'; - $items['body'] = 'This is the hook!'; - } - -} - -echo new Page('index.tpl'); - -``` - -index.tpl - -``` - -

{$title}

-

{$body}

- -``` - -Output - -``` - -

Hello World

-

This is the hook!

- -``` diff --git a/docs/Features/Ignored parts (escaping Div parsing).md b/docs/Features/Ignored parts (escaping Div parsing).md deleted file mode 100644 index 860cfce..0000000 --- a/docs/Features/Ignored parts (escaping Div parsing).md +++ /dev/null @@ -1,35 +0,0 @@ -The way of define a part of the template and ignore their code. - -**Syntax in templates** - -``` -{ignore} -     -... some ignored code here ... -     -{/ignore} -``` - -**Example** - -index.php - -``` -echo new div('index.tpl', ['name' => "Peter"]); -``` - -index.tpl - -``` -{ignore} - -Name: {$name} - -{/ignore} -``` - -Output - -``` -Name: {$name} -``` diff --git a/docs/Features/Including another templates.md b/docs/Features/Including another templates.md deleted file mode 100644 index 945e9b3..0000000 --- a/docs/Features/Including another templates.md +++ /dev/null @@ -1,45 +0,0 @@ -A complex design, require split of the template. Then you can include the design's parts in a container template. - -Syntax in templates - -``` - -{% var with path to the template's part %} - -OR - -{% path/to/the/template/part %} - -``` - -Example - -part.tpl - -``` -Hello world! -``` - -index.tpl - -``` - -This is the container template: - -{% part %} - -``` - -Output - -``` - -This is the container template: - -Hello world! - -``` - -Important: - -The engine does not accept that a template is included itself. diff --git a/docs/Features/Including pre-processed templates.md b/docs/Features/Including pre-processed templates.md deleted file mode 100644 index 127d4a9..0000000 --- a/docs/Features/Including pre-processed templates.md +++ /dev/null @@ -1,69 +0,0 @@ -Similar to [[Including another templates]], but in this case, first the engine parse the template, and then include it. - -Syntax in templates - -``` - -{%% var with path to the template's part %%} - -OR - -{%% path/to/the/template/part %%} - -``` - -Example - -index.php - -``` - 'Unnamed', - 'products' => [ - ['name' => 'Banana'], - ['name' => 'Potato'] - ] -]); - -``` - -index.tpl - -``` - -Include: - -[$products] - {% part %} -[/$products] - -Preprocessed: - -[$products] - {%% part %%} -[/$products] - -``` - -part.tpl - -``` - -{$name} - -``` - -Output - -``` - -Banana - -Potato - -Unnamed - -Unnamed -``` \ No newline at end of file diff --git a/docs/Features/Iterations.md b/docs/Features/Iterations.md deleted file mode 100644 index 749f7bc..0000000 --- a/docs/Features/Iterations.md +++ /dev/null @@ -1,29 +0,0 @@ -This feature is for perform a N iterations of a loop. The iterations are loops that increment a variable in each cycle. The value of this variable can be accessed by **$value**. You can also specify the name of the variable and the steps of the increments. - -Syntax: - -``` -[:from,to,var,step:] - ... some code here ... -[/] -``` - -Example: - -index.tpl - -``` - -[:1,10:] {$value} [/] -[:1,10,x:] {$x} [/] -[:1,10,x,2:] {$x} [/] -``` - -Output: - -``` - 1 2 3 4 5 6 7 8 9 10 - 1 2 3 4 5 6 7 8 9 10 - 1 3 5 7 9 -``` - diff --git a/docs/Features/Locations.md b/docs/Features/Locations.md deleted file mode 100644 index 8a388fd..0000000 --- a/docs/Features/Locations.md +++ /dev/null @@ -1,80 +0,0 @@ -The locations are tags that identify some positions into template. With this feature you can define a location in any part of the template, and then collocate any content in this location. The tag that represent the location can be repeated in other positions. Also, you can locate several template pieces in the same location. - -Now you can separate two concepts: the content from their location in the template. This advantage can be resolved with [[Simple replacements]] of  [[Template's variables]] but this is not sufficient and it is not equal. - -Syntax - -``` -Define the location: - -(( location_name )) - -Define the content: - -{{location_name - -... some content here ... - -location_name}} -``` - -Example - -layout.tpl - -``` - - - -
(( content ))
- - - -``` - -index.tpl - -``` -{% layout %} - -{{header - This is the header -header}} - -{{footer - This is the footer -footer}} - -{{content - This is the content -content}} - -{{header -
.... more in the header ..... -header}} - -``` - -Output - -``` - - - -
This is the content
- - - -``` - -## Clearing location tags - -By default Div removes location tags after parsing. You can control this during parse cycles with the setup var `div.clear_locations`. - -Example: - -``` -{= div.clear_locations: false =} -``` - -This keeps location tags while composing pre-processed templates; remaining location tags are cleared at the end of the top-level parse. diff --git a/docs/Features/Macros.md b/docs/Features/Macros.md deleted file mode 100644 index ffaf0e5..0000000 --- a/docs/Features/Macros.md +++ /dev/null @@ -1,110 +0,0 @@ -A macro is a restricted PHP code dedicated to execute the design's complex tasks. For this reason, Div assures that the PHP code will be not intrusive or insecure. - -Syntax - -``` - -``` - -Example - -index.php - -``` - ['Banana', 'Potato'] -]); -``` - -index.tpl - -``` - -{= text: "hello" =} - -{$text} - - - -{$text} - -Products: - - - -They are {$i} products - -``` - -Output - -``` -hello - -HELLO - -Products: - -1 - Banana -2 - Potato - -They are 2 products -``` - -## Restrictions - -- It is not allowed to use **$this** or **self** -- It is only allowed to use [some functions of PHP](https://divengine.org/documentation/div-php-template-engine/features/macros#allowed-php-functions) by default. You can enable the use of another function through the method [setAllowedFunction](https://divengine.org/documentation/div-php-template-engine/features/macros#div-methods). -- It is not allowed to create functions neither classes. -- It is not allowed to include other script. - -## Features - -- Create new template's variables -- Change the value of any template's variable -- ECHO any content (take care of not provoking an infinite loop) -- Use the allowed methods of div as a functions: - - asThis - - atLeastOneString - - getCountOfParagraphs - - getCountOfSentences - - getCountOfWords - - getLastKeyOfArray - - getRanges - - htmlToText - - isArrayOfArray - - isArrayOfObjects - - isCli - - isNumericList - - isString - - jsonDecode - - jsonEncode - - mixedBool -- Use the methods of current class without restrictions if it is a [class that extends div](https://divengine.org/documentation/div-php-template-engine/features/macros#oop) \ No newline at end of file diff --git a/docs/Features/Multi replacements.md b/docs/Features/Multi replacements.md deleted file mode 100644 index 42bf80f..0000000 --- a/docs/Features/Multi replacements.md +++ /dev/null @@ -1,69 +0,0 @@ -Replace X with Y. - -Syntax in templates - -``` - -{:varname} - ... some code here ... -{:/varname} - -``` - -The variable should be an array where each item of array is an array with 3 element: **string to search**, **string to replace** and **use or not regular expressions**. - -Example - -index.php - -``` - [ - ['[b]', ''], - ['[/b]', ''] - ], - - /* preg_replace */ - 'highlight' => [ - ['/\*.*\*/', '$0', true] - ] -]); -``` - -index.tpl - -``` -{= htmlfix: [ - ['',''] - ['',''] -] =} - -{:customtags} -{:htmlfix} - -[b]Hello World[/b] - -{:/htmlfix} -{:/customtags} - -{:highlight} - -/* this is a PHP comment */ - -{:/highlight} - -``` - -Output - -``` - -Hello World - -/* this is a PHP comment */ - -``` \ No newline at end of file diff --git a/docs/Features/Object Oriented Programming.md b/docs/Features/Object Oriented Programming.md deleted file mode 100644 index 0ed51e5..0000000 --- a/docs/Features/Object Oriented Programming.md +++ /dev/null @@ -1,98 +0,0 @@ -In this section you can learn how the programmer can create classes that inherits from the **div** class. - -The constructor should respect the parent's constructor. Change the default constructor is not recommended. IMPORTANT: The recommended way for do something before build is the implementation of [**beforeBuild()** hook](https://divengine.org/docs/div-php-template-engine/features/object-oriented-programming#hooks). - -Note: If $src is null and $__src is not set, Div derives the template path from the subclass file name (via Reflection). Example: `MyPage.php` -> `MyPage.tpl` in the same directory. Pass $src explicitly to override this behavior. - -``` - 'Banana', - 'price' => 20 - ], - [ - 'name' => 'Potato', - 'price' => 30 - ] - ]; - } - - public function sum($x, $y){ - return $x + $y; - } - -} -``` - -index.tpl - -``` - -{= products: ->getProducts() =} -{= result: ->sum(20,30) =} - -[$products] - {$name} -[/$products] - -{$result} - -``` - -Output - -``` - -Banana -Potato - -50 - -``` - -The arrow symbol used to get a method's result in the template example, can not be changed with a custom dialect. Is a strict rule in Div. - -[[The __toString magic method]] -[[Content like an object (intelligent data)]] - diff --git a/docs/Features/Pre-defined sub-parsers.md b/docs/Features/Pre-defined sub-parsers.md deleted file mode 100644 index 6da432c..0000000 --- a/docs/Features/Pre-defined sub-parsers.md +++ /dev/null @@ -1,3 +0,0 @@ -Div provide pre-defined sub-parsers. See the next list: - -- **{parse} ... {/parse}**: Make a pre-proccess of enclosed code. This means that a new instance of div will be created, similar to the loops and the capsules. diff --git a/docs/Features/Simple replacements.md b/docs/Features/Simple replacements.md deleted file mode 100644 index 77f045d..0000000 --- a/docs/Features/Simple replacements.md +++ /dev/null @@ -1,41 +0,0 @@ -A simple replacement is the replacement of parts of the template with any content. The variable can be contain a mixed value: - -- If the value is a string, the replacement is the string. -- If the value is a number, the replacement is the "number". -- If the value is an array, the replacement is the length of the array. -- If the value is an object without __toString method implemented, the replacement is the count of properties of the object. - -**Syntax in templates** - -``` -{$varname} -``` - -**Example:** - -**index.php** - -``` - 'Peter', - 'last_name' => 'Pan' -]); -``` - -**index.tpl** - -``` -First name: {$first_name} -Last name: {$last_name} -``` - -**Output** - -``` -First name: Peter -Last name: Pan -``` \ No newline at end of file diff --git a/docs/Features/String's dissection.md b/docs/Features/String's dissection.md deleted file mode 100644 index 2c33d4f..0000000 --- a/docs/Features/String's dissection.md +++ /dev/null @@ -1,42 +0,0 @@ -The scalar values as a complex values. All the scalar values can be used as a strings. Then, the strings can be used like complex values, that is to say, as group of characters. For example: - -``` -{= name: "Peter" =} - - -{$name.0} - - -{$name.1} - -{= x: 537 =} - - -{$x.0} - - -{$x.1} - - -[$name]{$value} [/$name] - - -[$x] {$value} * [/$x] = (# [$x] {$value} * [/$x] 1 #) -``` - -Output - -``` -P - -e - -5 - -3 - -P e t e r - -5 * 3 * 7 = 105 -``` - diff --git a/docs/Features/Sub-parser's events.md b/docs/Features/Sub-parser's events.md deleted file mode 100644 index 3aa25a3..0000000 --- a/docs/Features/Sub-parser's events.md +++ /dev/null @@ -1,47 +0,0 @@ -Each sub-parser is processed in some different moments. At the moment, the events are: beforeParse, afterInclude and afterParse. Now in the templates's code you can specify when a sub-parser will be executed. The moment, or the event, can be specified in the template as following example: - -index.tpl - -``` -{= name: "Peter" =} -{= products: [ - { - name: "banana", - price: 40 - }, - { - name: "potato", - price: 25 - } -] =} - -[$products] - {parse:beforeParse} - Name: {$name} - {/parse:beforeParse} - - Product name: {$name} - - {% other %} -[/$products] - -``` - -other.tpl - -``` -{parse:beforeParse} - Other name: {$name} -{/parse:beforeParse} -``` - -Output - -``` -Name: Peter -Product name: banana -Other name: banana -Name: Peter -Product name: potato -Other name: potato -``` diff --git a/docs/Features/Sub-parsers.md b/docs/Features/Sub-parsers.md deleted file mode 100644 index ba64e13..0000000 --- a/docs/Features/Sub-parsers.md +++ /dev/null @@ -1,133 +0,0 @@ -The sub-parsers are parsers that run before the main parser of div, like as [[Ignored parts (escaping Div parsing)]] . The custom sub-parsers are built by the programmer to perform _pre-processing_ part of the template. The PHP implementation can be a function or static method. If you have implemented [**a class that inherits from div**](https://divengine.org/documentation/div-php-template-engine/features/custom-sub-parsers#oop), and uses it to process your templates, then the sub-parser can be implemented in any method of that class. - -For security reasons, the sub-parsers implemented as functions and static methods, must be registered prior to processing the template with **div::setSubParser()** method. Each sub-parser receive the template code to process and optionally the information provided to the engine. The string returned by the sub-parser will replace the content between pre-parse's tags. - -Syntax in templates - -``` -{sub-parser-name} - - ... this code will be sent to the sub-parser function/method ... - -{/sub-parser-name} - - -``` - -Example - -index.php - -``` -'.$code.'

'; - return ""; -} - -/* Sub-parser as a method */ -class MyPage extends div{ - - /* You can set the sub-parsers in the constructor */ - public function beforeBuild(){ - - // Sub-parser with their name different to the name of function - self::setSubParser('combobox', 'buildCombobox'); - } - - /* A sub-parser ... */ - public function buildCombobox($properties){ - - $prop = self::jsonDecode('{'.$properties.'}'); - - $html = "\n"; - - return $html; - } - - /* Other sub-parser */ - public function upperthis($text, &$items){ - $text = trim($text); - if (self::issetVar($text, $items)) { - $items[$text] = strtoupper($items[$text]); - } - } -} - -/* Set sub-parsers before */ - -/* Same as MyPage::setSubParser("literal", "literal"); */ -MyPage::setSubParser('literal'); - -/* Alias for 'literal' */ -MyPage::setSubParser('noparse','literal'); - -/* Name of sub-parser equal to name of function */ -MyPage::setSubParser('body'); - -/* Similar way ... */ -div::setSubParser('upperthis'); - -echo new MyPage('index.tpl'); - -``` - -index.tpl - -``` -{body} - Hello world, this is my first sub-parser -{/body} - -{combobox} - name: 'cboCities', - options: [ - {v: 'NY', c: 'New York'}, - {v: 'PA', c: 'Paris'}, - {v: 'TK', c: 'Tokio'} - ] -{/combobox} - -{upperthis}body{/upperthis} - -{$body} - -{literal} - {$body} -{/literal} - -``` - -Output - -``` - - -

- HELLO WORLD, THIS IS MY FIRST SUB-PARSER -

- -{$body} - -``` - -[[Pre-defined sub-parsers]] -[[Sub-parser's events]] - diff --git a/docs/Features/System vars.md b/docs/Features/System vars.md deleted file mode 100644 index 2b4b738..0000000 --- a/docs/Features/System vars.md +++ /dev/null @@ -1,75 +0,0 @@ -## $div reserved variable - -Some system vars are available in the templates. This vars are provided by the engine. The following table shows the system vars: - -|System var|Description| -|---|---| -|div.now|The result of **time()** PHP function| -|div.post|$_POST| -|div.get|$_GET| -|div.server|$_SERVER| -|div.session|$_SESSION| -|div.version|div::$__version| -|div.script_name|The cuurent script file name - $_SERVER['SCRIPT_NAME']| -|div.ascii|The ASCII chars. For example, the **{$div.ascii.64}** to replace with character 64 (@ symbol). You don't made a mistake, this replacement is different to use the HTML entities just as "**@**".| - -Now then, all the variables of the system are not enabled by default. The system vars enabled by default are **div.now**, **div.version**, **div.get** and **div.post**. - -If you need enable some system vars use the method **div::enableSystemVar($varname)**. If you need disable a system var use the method **div::disableSystemVar($varname)**. - -## Engine setup vars - -The engine also reads some setup vars from your items/template variables. These are not system vars, but they affect parsing: - -- `div.literals`: list of variable names treated as literal (skip further parsing). You can set it in the template or in PHP. Example: `{= div.literals: ["text1", "text2"] =}`. PHP equivalent: `$tpl->addLiteral(["text1", "text2"]);` -- `div.clear_locations`: boolean flag that controls whether location tags are cleared during parse cycles. If false, locations are kept for further composition (useful with pre-processed templates). At the end of the top-level parse, remaining location tags are cleared. - - -Example - -index.php - -```php -
echo div::getDocsReadable(null, array('title' => 'My docs'));| -|name|Template's name| -|description|Description of the template in one line| -|version|Version of the template| -|author|Author| -|update|Date of last update| -|vars|List of the template's variables. The fourth part can contain several spaces, but the three first not, because Div considers them as words. Remember that this is specifically for the documentation template that Div provides. You can build your own documentation template with defined variables by your work team:

1. optional/required
2. data type
3. variable's name
4. variable's description

For example:

| -|include|The list of included templates. The parser will add all includes automatically. Also you can specify it, for example, when the include tag use a variable and not the template's specific path.| -|example|The example of how to use this template| - -Syntax in templates - -```html -<--{ - - ... unsaved content here .... - - @fist_saved_property value - @other_property value - @other_property value - @other_property value - @multiline_property: line1 - line2 - line3 - @other_multiline_property: - line1 - line2 - line3 - ... - -}--> -``` - -Example - -index.tpl - -```html -<--{ - - The next comments are the documentation of this template - - @name My template - @description My first template with documentation - @author Me - @vars: required string title - optional string body - - @example: - {= title: "My first blog" =} - {= body: "This is my first blog" =} - {% blog.tpl %} - -}--> -``` - -index.php - -```php -parse(); - -echo $tpl->getDocsReadable(); -``` diff --git a/docs/Features/Template's properties.md b/docs/Features/Template's properties.md deleted file mode 100644 index 706cba5..0000000 --- a/docs/Features/Template's properties.md +++ /dev/null @@ -1,15 +0,0 @@ -Each template can have properties and the designer is responsible for establishing them. The properties apply only to the file where they are defined. - -The properties are defined in a single line using the following syntax: - -```html -@_property_name = property's value -``` - -For example, the following code sets the dialect of the template, where the value is the name of the file containing the dialect. - -```html -@_DIALECT = smarty.dialect -``` - -Properties are identified by the prefix **@\_.** diff --git a/docs/Features/Template's variables.md b/docs/Features/Template's variables.md deleted file mode 100644 index 66f463a..0000000 --- a/docs/Features/Template's variables.md +++ /dev/null @@ -1,144 +0,0 @@ -This feature is dedicated to designers. The designers can declare variables in the template and to use them for different reasons. - -The **values** of variables can be: - -- A string -- Another var -- An object or an array in JSON -- A call to method of the current PHP class -- The path of JSON file - -**Important:**If the value is not valid JSON, it will be considered as a template and will be parsed before decoding. See the next sequence: - -``` -1. Value is not valid JSON: {= digits: [[:0,8:]{$value},[/]9] =} -2. Value was parsed: {= digits: [0,1,2,3,4,5,6,7,8,9] =} -3. Now "digists" is an array. -4. Replacement: {$digits} -``` - -See the difference: - -``` -1. Value is valid JSON: {= digits: "[[:0,8:]{$value},[/]9]" =} -2. Value was not parsed: {= digits: "[[:0,8:]{$value},[/]9]" =} -3. Now "digists" is an string. -4. Replacement: {$digits} -``` - -Syntax: - -``` -{= varname: ... value ... =} - -A string - -{= varname: some string here =} - -An array in JSON - -{= varname: [item1, item2, .... ] =} - -An object in JSON - -{= varname: { - prop1: value1, - prop2: value2, - ... -} =} - -Get the value of another var - -{= var1: value1 =} -{= var2: $var1 =} - -Call to method of current PHP class - -{= sum: ->sum(20,30) =} - -``` - -See also [OOP section.](https://divengine.org/documentation/div-php-template-engine/features/templates-variables#oop) - -Note: the `$` used inside template variable values (for example `{= var2: $var1 =}`) is a fixed token and is not affected by dialect changes. Changing `DIV_TAG_MODIFIER_SIMPLE` only affects replacements in template output. - -Example: - -index.php - -``` - -echo new div('index.tpl', [ - 'price' => 40 -]); -``` - -index.tpl - -``` - -{= price: 20 =} - -Price: {$price} - -{= labels: ['A','B','C','D'] =} - -Labels: [$labels] {$value}!$_is_last, $_is_last! [/$labels] - -{= product: { - name: "Potato", - price: 45 - } =} - -Product: {$product.name} - -Product's price: {$product.price} - -{= somestring: Blah blah blah =} - -String: {$somestring} - -{= somevar: $price =} - -Some var: {$somevar} -``` - -Output: - -``` -Price: 40 - -Labels: A, B, C, D - -Product's price: Potato - -Price: 45 - -String: Blah blah blah - -Some var: 40 -``` - -## Protected template's vars - -To protect the value of a teplate's variable, type an asterisk (*) before the variable's name: - -``` - -{= *protectedvar: "protected value" =} - -``` - -Protect a template's variable means that after this protection, any intent of changing its value will be failed. - -## How to load the content of an external template into a variable? - -If you have a external template and its content is needed into a variable, the next trick can help you: - -``` - -{= varname: {% external-template %} =} - -``` - -The "external content" are loaded "on demand". This means that the content will be loaded in first replacement of variable. diff --git a/docs/Features/The __toString magic method.md b/docs/Features/The __toString magic method.md deleted file mode 100644 index 3c888cd..0000000 --- a/docs/Features/The __toString magic method.md +++ /dev/null @@ -1,154 +0,0 @@ -If an object has implemented the method __toString, you can work with the object as a character string in three possible scopes: template's scope, loop body's scope and capsule's scope. You can use two possible variables to put the content returned by the implemented __toString() method: - -- The variable **$_to_string** in template's scope. -- The variables **$_to_string** and **$value** in capsule and loop's body scopes. - - -Suppose that you have the following class: - -Person.php - -``` - -class Person{ - - public function __construct($first_name, $last_name){ - $this->first_name = $first_name; - $this->last_name; - } - - public function __toString(){ - return $this->first_name." ".$this->last_name; - } - -} - -``` - -Then, the following examples show the use of the variables: - -Example 1: Template's scope - -index.php - -``` - - -include 'div.php'; - -include 'Person.php'; - -echo new div('index.tpl', new Person("Albert", "Einstein")); - -``` - -index.tpl - -``` - -{$_to_string} - -``` - -Outpput - -``` - -Albert Einstein - -``` - -Example 2: Loop body's scope - -index.php - -``` - [ - new Person("Albert", "Einstein"), - new Person("John", "Nash") - ] -)); - -``` - -index.tpl - -``` - -If Person not have a $value property: - -[$persons] - {$value} -[/$persons] - -You can always use the variable $_to_string: - -[$persons] - {^^^_to_string} -[/$persons] - -``` - -Output - -``` - -If Person not have a $value property: - - Albert Einstein - John Nash - -You can always use the variable $_to_string: - - ALBERT EINSTEIN - JOHN NASH - -``` - -Example 3: Capsule's scope - -index.php - -``` - new Person("Albert", "Einstein") -]); - -``` - -index.tpl - -``` - -[[person - - {$_to_string} - - {^^^value} - -person]] - -``` - -Output - -``` - -Albert Einstein - -ALBERT EINSTEIN - -``` \ No newline at end of file diff --git a/docs/Features/Understanding the syntax.md b/docs/Features/Understanding the syntax.md deleted file mode 100644 index ada389d..0000000 --- a/docs/Features/Understanding the syntax.md +++ /dev/null @@ -1,47 +0,0 @@ -Div parse the template language locating some syntax structures that have rules. In this section the structures and their rules are explained. - -#### Rigid blocks -![[Pasted image 20240128115015.png]] - -| | | | -|---|---|---| -|PREFIX|RIGID SYNTAX|SUFFIX| - -The rigid blocks are those that are compound for a rigid syntaxis with prefix and a suffix. The rigid syntax is that in the one that each character has a meaning for the interpreter, in such way that characters are not allowed of more. That is to say, characters like the space (chr(32)), the tabs (\t) and the new lines (\n), that allow to beautify the code, won't be ignored by the interpreter and it will consider them like part of their syntactic analysis. In this blocks, the prefix and the suffix are required. - -For example, if you write **"{$text }"** the name of the variable to substitute will include the space at the end, that is to say, it will be **"text "**. - -Example of rigid blocks are [[Simple replacements]] and [[Including another templates]]. - -#### Simple blocks - -| | | | -|---|---|---| -|BEGIN|FLEXIBLE SYNTAX|END| - -The simple blocks are similar to the rigid blocks, with the difference that the prefix is named "begin", the suffix is named "end", and the syntaxis of the block is flexible. A flexible syntax is the opposite to a rigid syntax, where it is allowed to write characters to space or to format. In this blocks, the aperture tag and the closing tag are required. - -Example of simple blocks are [[Ignored parts (escaping Div parsing)]], [[Comments]] and [[Strip or clean the resulting code]] -#### No-keyword blocks - -| | | | -|---|---|---| -|BEGIN_PREFIX|FLEXIBLE SYNTAX|BEGIN_SUFFIX| -|ANY CODE + SPECIAL TAGS| | | -|END| - -The blocks without keywords are those where the aperture tag and the closing tag have a structure or specific content, so that it is not necessary a prefix and a suffix for the closing tag. In this sense the prefix and the suffix of the aperture tag are required, and as well as the closing tag. - -Example of no-keyword blocks are [[Conditions]] and [[Iterations]] - -#### Keyword blocks - -| | | | -|---|---|---| -|BEGIN_PREFIX|KEYWORD|BEGIN_SUFFIX| -|ANY CODE + SPECIAL TAGS| | | -|END_PREFIX|KEYWORD|END_SUFFIX| - -The blocks with keywords are those where the aperture tag and the closing tag contain the name a variable, either simple or complex, accompanied by a prefix and a suffix in both cases. The prefix of the aperture tag and the suffix of the closing tag are required. - -Example of keyword blocks are [[Conditional parts]] and [[Lists (loops)]] diff --git a/docs/Features/Variable's modifiers.md b/docs/Features/Variable's modifiers.md deleted file mode 100644 index 3fad7c3..0000000 --- a/docs/Features/Variable's modifiers.md +++ /dev/null @@ -1,125 +0,0 @@ -Variable's modifiers allow you to change the value of a variable or obtain information about the value in the templates, so they change the way they are displayed, such as a text in capital letters, etc.. - -**Syntax in templates:** - -The following variable's modifiers can be used with the current version of Div: - -|Modifier|Description| -|---|---| -|{$variable}|Nonthing to change| -|{^variable}|Capitalize the first character of the string.| -|{^^variable}|Capitalize the first character of each word of the string.| -|{^^^variable}|Convert the entire string to uppercase.| -|{_variable}|Convert the entire string to lowercase.| -|{%variable}|Count of characters.| -|{%%variable}|Count of words.| -|{%%%variable}|Count of sentences.| -|{%%%%variable}|Count of paragraphs.| -|{&variable}|URL encode (see also [urlencode](http://www.php.net/manual/en/function.urlenconde.php)).| -|{&&variable}|Raw URL encode (see also [rawurlencode](http://www.php.net/manual/en/function.rawurlenconde.php)).| -|{html:variable}|Convert all aplicable characters to HTML entities (see also [htmlentities](http://www.php.net/manual/en/function.htmlentities.php)).| -|{br:variable}|Convert new lines to HTML line breaks (see also [nl2br](http://www.php.net/manual/en/function.nl2br.php)).| -|{json:variable}|Encode the value as JSON.| -|{[other-modifier]variable:~truncate-length}|Truncate the content for create a teaser content. If the content have the break tag (****) the parser truncate the content in this tag.| -|{[other-modifier]variable:/wordwrap-length}|Word wrap.| -|{[other-modifier]variable:from,length}|Sub-string| -|{'variable}|Escape unescaped single quotes| -|{js:variable}|Output JavaScript code (or similar) - Escape quotes and backslashes, newlines, etc.| -|{$variable:[string format]}|Format the string with [sprintf](http://www.php.net/manual/en/function.srpintf.php) PHP function| - -**Example:** - -index.tpl - -```html -{= title: mozilla firefox =} -{= body: A wonderful web browser=} - -Nothing to change: -{$title} - -Capitalize the first character of the string: -{^title} - -Capitalize the first character of each word of the string: -{^^title} - -Convert the entire string to uppercase: -{^^^title} - -Convert the entire string to lowercase: -{_title} - -Count of characters: -{%title} - -Sub-string: - -{$body:0,11} - -Truncate: - -{$body:~25}... - -Word wrap: - -{$body:/30} - -Combining the modifiers: - -{^^^body:0,11} - -{^^^body:/40} - -String format: - -{= value: 10 =} - -{$value:%1$04d} -``` - -Output: - -```html -Nothing to change: -mozilla firefox - -Capitalize the first character of the string: -Mozilla firefox - -Capitalize the first character of each word of the string: -Mozilla Firefox - -Convert to uppercase: -MOZILLA FIREFOX - -Convert to lowercase: -mozilla firefox - -Count of characters: -15 - -Sub-string: -web browser - -Truncate: -A wonderful... - -Word wrap: -A wonderful web browser - - -Combining the modifiers: -A WONDERFUL WEB BROWSER - -A WONDERFUL - - -String format: - -0010 -``` - -[[Custom modifiers]] -[[Multiple variable's modifiers]] - diff --git a/docs/Features/Variables (information, content...).md b/docs/Features/Variables (information, content...).md deleted file mode 100644 index 3a89ad6..0000000 --- a/docs/Features/Variables (information, content...).md +++ /dev/null @@ -1,55 +0,0 @@ -The designer doesn't have reason to know what are a data type to make their work. It should simply consider to the variables of the design as "the information". For this reason, in the templates, Div normalizes all the information coming from PHP, considering an array, objects or combination of arrays and objects as "same things". - -The information represents a hierarchy. You can access to all thier "pieces" using the dot "." operator. - -Example: - -**index.php** - -```php - 'something', - 'complex' => [ - 'single' => 45, - 'subcomplex' => [ - 'single' => '60' - ] - ] -]); - -/* ... is similar to ... */ - -$complex = (object) [ - 'single' => 45, - 'subcomplex' => [ 'single' => 60 ] - -]; - -echo new div('index.tpl', [ - 'single' => 'something', - 'complex' => $complex -]); - -``` - -**index.tpl** - -```php -Single value: {$single} -Single value into complex var: {$complex.single} -And more: {$complex.subcomplex.single} -``` - -**Output** - -```php -Single value: something -Single value into complex var: 45 -And more: 60 -``` - -[[String's dissection]] diff --git a/docs/Ignore specific variables (the third parameter of constructor).md b/docs/Ignore specific variables (the third parameter of constructor).md deleted file mode 100644 index 713f60d..0000000 --- a/docs/Ignore specific variables (the third parameter of constructor).md +++ /dev/null @@ -1,11 +0,0 @@ -If you want that the engine ignore some variables in template, specify the variables as a list of names in the third parameter of constructor: - -```php -/* Third parameter as array */ - -echo new div('index.tpl', ['name' => 'Peter'], ['name']); - -/* Third parameter as string */ - -echo new div('index.tpl',['name' => 'Peter', 'age' => 25, 'sex' => 'M'], 'name,age'); -``` diff --git a/docs/Introduction to Div PHP Template Engine.md b/docs/Introduction to Div PHP Template Engine.md deleted file mode 100644 index 11b1679..0000000 --- a/docs/Introduction to Div PHP Template Engine.md +++ /dev/null @@ -1,36 +0,0 @@ -Div is a [template] engine and [code generator tool] written in [PHP](http://php.net/) and developed since 2011, that allows the separation of labor between developers and designers, and improve the software development based on [Generative Programming], [Model Driven Architecture] and [Meta programming]. - -As the designer or developer built templates with some specific tags, other developers or designers uses the template to replace these tags with data or more template code. Div have a compact, flexible and descriptive syntax for templates: - -- "compact" means "a minimum of code for template language" -- "flexible" means "you can create dialects of template language" -- "descriptive" means "template language talk by herself" - -This project is the main piece of the organization [Div Software Solutions](https://divengine.com/), following the philosophy of "build more with less" and "divide the problem and not to the people". To obtain this goal, Div propose the [code generation based on templates], following this rules: - -1. The **model** will have all information about _"what do you want to do"_ -2. The **templates** will have all information about _"what results you expect"_ -3. The **engine** if the black-box that achieve the _"how to make it"_. - -Then, exists these basics operations: - -- Operation #1. **Compile** a template with models and save the result -- Operation #2. **Transform** a model to another, reusing Operation #1. -- Operation #3. **Compose** different results, using the engine and other tools. - -When you have white these rules, then you will be able to use your imagination and you will be able to achieve the following results, and any combination of them: - -1. Avoid repetitive tasks in the programming -2. Save your models and reuse them in another project -3. Scaling your project based in your models. -4. Migrate your project to different technology -5. Take advantage of your models and develop parallel versions -6. Expand your application in other platforms and devices -7. Improve the performance of your application -8. Make a documentation of your work -9. Involve the "non technician" people in the development of the project - -[[Goals]] -[[Possibilities for the designer]] -[[Possibilities for the programmer]] -[[Reasons]] \ No newline at end of file diff --git a/docs/Introduction/Goals.md b/docs/Introduction/Goals.md deleted file mode 100644 index 909d70c..0000000 --- a/docs/Introduction/Goals.md +++ /dev/null @@ -1,6 +0,0 @@ -- One class, one file! Considering the template as an object. -- Create a minimum of highly descriptive syntax. -- Avoid a caching system. -- Improve algorithms. -- Reuse knowledge, write mechanisms and extend! -- \ No newline at end of file diff --git a/docs/Introduction/Possibilities for the designer.md b/docs/Introduction/Possibilities for the designer.md deleted file mode 100644 index 6fd6dbb..0000000 --- a/docs/Introduction/Possibilities for the designer.md +++ /dev/null @@ -1,23 +0,0 @@ -The designer carries out its work in text files and he can use different tags. Div does not provide for the design obtrusive code. All that is programmed in the templates has a single goal: design. - -- Replace tags -- Apply [variable's modifiers](https://divengine.org/docs/div-php-template-engine/introduction/possibilities-designer#variable-modifiers): uppercase, lowercase, word count, paragraph count, string length, URL encode, convert everything to HTML entities -- Working with substrings -- Loops, iterations, cycles or repetitive parts -- Parts of templates displayed conditionally -- Evaluation conditions -- Definition of variables -- Divide the design into parts and then include or pre-process it -- Formatting Numbers and Dates -- Working with Formulas -- Comments -- Position of content -- Recursion: the engine processes the template over and over again until there is nothing to process -- Mechanism for the inheritance among templates -- Ignoring parts of the template -- Access to any specific value of the information passed by the programmer -- Access to methods of information's objects -- Aggregate functions: sum, average, minimum, maximum, count on. -- Clean the output -- Convert HTML to readable text -- Using the custom [subparsers](https://divengine.org/docs/div-php-template-engine/introduction/possibilities-designer#subparsers) implemented by the programmer. \ No newline at end of file diff --git a/docs/Introduction/Possibilities for the programmer.md b/docs/Introduction/Possibilities for the programmer.md deleted file mode 100644 index d2f30eb..0000000 --- a/docs/Introduction/Possibilities for the programmer.md +++ /dev/null @@ -1,13 +0,0 @@ -The programmer creates an instance of div class, specifying in its constructor, the template created by the designer and the information that will be displayed. - -- Rename the div class -- Define default file extensions -- Div class inheritance and object-oriented programming -- Define variables -- Defining global variables -- Define replacement values per variable -- Load data from a JSON file -- Ignore information variables passed to the constructor of the div class -- Debug -- Use class div instance as a string -- Implement some hooks diff --git a/docs/Introduction/Reasons.md b/docs/Introduction/Reasons.md deleted file mode 100644 index 0210e48..0000000 --- a/docs/Introduction/Reasons.md +++ /dev/null @@ -1,11 +0,0 @@ -Div is developed with the philosophy of reused knowledge. Of course, Div is released at the time of the well-known template engines that are widely used. For this reason, Div develops a minimum of new knowledge so that developers can quickly become familiar with this engine and understand when, how and why to use it. - -Features are added if really needed. That is, if there is a need to add other functionality, we first analyze whether there is a mechanism to resolve this functionality, and then publish an article explaining how to implement this mechanism. - -The argument for developing Div was obtained from several tests with PHP and we concluded that it is faster to replace the parts of the string than scripts included in PHP. - -The fact is that substring replacement is a fast process but requires more memory. However, this consumption is so small that it is worth the sacrifice. - -The development of div is to avoid creating a caching system because we believe that it is unnecessary based on its characteristics as an engine. A learning system may be enough: it can avoid repeated processing of the same templates. - -Finally, the most popular engines are known to be composed of more than one file, classes, and libraries. Div sought from its inception, the implementation of everything in a single class, in a single file. This allows easy adaptation to existing development platforms. \ No newline at end of file diff --git a/docs/Mechanisms.md b/docs/Mechanisms.md deleted file mode 100644 index 988c58b..0000000 --- a/docs/Mechanisms.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -icon: FabReadme ---- -[[Components]] -[[Recursion]] -[[Templates inheritance]] diff --git a/docs/Mechanisms/Components.md b/docs/Mechanisms/Components.md deleted file mode 100644 index 4c28554..0000000 --- a/docs/Mechanisms/Components.md +++ /dev/null @@ -1,57 +0,0 @@ -Complex GUIs are created with components. A component can reduces the effort dedicated in the production. Create a component with Div and for Div, is a very simple mechanism to implement. See the next example: - -#### 1. Create the component: - -**combobox.tpl** - -``` - -``` - -This component use: [simple replacements](https://divengine.org/documentation/div-php-template-engine/mechanisms/components#simple-replacements), [lists](https://divengine.org/documentation/div-php-template-engine/mechanisms/components#lists) and [recursion](https://divengine.org/documentation/div-php-template-engine/mechanisms/components#recursion). - -#### 2. Use your component: - -**index.tpl** - -``` -[[_empty - {= id: "products" =} - {= name: "products" =} - {= options: "products" =} - {% combobox %} -_empty]] -``` - -"Use a component" means "[include](https://divengine.org/documentation/div-php-template-engine/mechanisms/components#include) the component", for example, into a [capsule](https://divengine.org/documentation/div-php-template-engine/mechanisms/components#capsules), that can be the _empty variable. - -#### 3. Write your PHP code: - -**index.php** - -``` - [ - ['val' => 1, 'text' => 'Banana'], - ['val' => 2, 'text' => 'Potato'], - ['val' => 3, 'text' => 'Apple'] - ] -]); -``` - -#### And when you run your script: - -``` - -``` - diff --git a/docs/Mechanisms/Recursion.md b/docs/Mechanisms/Recursion.md deleted file mode 100644 index 6a30d6a..0000000 --- a/docs/Mechanisms/Recursion.md +++ /dev/null @@ -1,77 +0,0 @@ -Div interprets the template until it is not anything to interpret. For that reason, the recursion is implicit and is an intrinsic characteristic of the eninge. - -If you have a code like '**{$\{$list}}**' and \$list = 'products' then the engine convert this code to '**{$products}**' and if you have another variable $products with your list of products, the engine replace it, in this example, with the count of products. - -Low performance? No! The implementation of Div is not a recursive algorithm. The recursion is only a mechanism for the designer. Don't worry. - -The recursion is very useful in the creation of [components](https://divengine.org/documentation/div-php-template-engine/mechanisms/recursion#components).  - -Example - -index.php - -``` -name = 'Banana'; -$product->price = 20.5; - -echo new div('index.tpl', [ - 'product' => $product, - 'object' => 'product' -]); -``` - -index.tpl - -Origin - -``` -[${$object}] - -{$_key} = {$value} - -[/${$object}] -``` - -Step 1 - -``` -[$product] - -{$_key} = {$value} - -[/$product] -``` - -Step 2 - -``` -[$product] - -name = {$value} - -[/$product] -``` - -Step 3 - -``` -[$product] - -name = Banana -price = {$value} - -[/$product] -``` - -Step 4 - -``` -name = Banana -price = 20.5 -``` diff --git a/docs/Mechanisms/Templates inheritance.md b/docs/Mechanisms/Templates inheritance.md deleted file mode 100644 index 3d3af08..0000000 --- a/docs/Mechanisms/Templates inheritance.md +++ /dev/null @@ -1,99 +0,0 @@ -The inheritance allows you to construct a base template that contains all the common elements and defines "zones" that other templates can change. At the moment Div doesn't provide the template inheritance explicitly. But we wonder if it is really necessary. - -For those that don't know about this topic, the template inheritance means that a template can inherit the design of another template and then redesign the necessary parts. - -The templates inheritance can be solved with inclusions in engines that don't provide the inheritance, but it can be a not very elegant solution. Does Div have some mechanism that can be considered a solution for the templates inheritance? - -Div considers that the templates inheritance can be solved with some of their features, like as inclusions, default values, template vars, locations and recursion. This section explain three variants for implement the inheritance. - -## Variant 1: Switch - -This way, when you write - -**{% block %}** - -Or - -**{% {$block} %}** - -the variable $block can have a default value and then this code can be include different templates. You can call this mechanism as "switch". - -### Variant 2: Using protected template's variables - -Another way to implement inheritance is using the template variables. In the parent template defines a block as it defines a template variable, then the variable positions in place of the template you want. In the child template redefines the "blocks" ([protected template's variables](https://divengine.org/documentation/div-php-template-engine/mechanisms/templates-inheritance#protected-template-vars)) and then includes the parent template. - -Example - -parent.tpl - -``` - ... any code ... -{= block1: - -... code of block 1 ... - -=} - -... another code... - -{$block1} -``` - -child.tpl - -``` -{= *block1: - - ... another code for block 1 ... - -=} - -{% parent %} -``` - -### Variant 3: Using locations - -This is the most elegant solution because you not need to define a variable. In the parent template you define the locations of the common content (for example "top", "header", "footer", "left", "right", etc), and then in the child template you can locate contents in the parent's locations. - -Example - -parent.tpl - -``` -... any code ... - -(( block1 )) - -... another code... - -{= parent_block1: - -... code block 1 written by the parent ... - -=} -``` - -child.tpl - -``` -{% parent %} - -{{block1 - - {$parent_block1} - -... The child's content ... - -block1}} -``` - -Output - -``` -... any code ... - -... code block 1 written by the parent ... -... The child's content ... - -... another code... -``` diff --git a/docs/Method's reference.md b/docs/Method's reference.md deleted file mode 100644 index 09913e2..0000000 --- a/docs/Method's reference.md +++ /dev/null @@ -1,167 +0,0 @@ -## Static methods - -**div::addCustomModifier(**string** $prefix, **string** $function)** - -Add a [custom variable's modifier](https://divengine.org/documentation/div-php-template-engine/methodss-reference#custom-modifiers). The modifier function should have a single parameter. - -**div::asThis(**mixed** $mixed)** - -Return mixed value as HTML format, (util for debug and fast presentation) - -**div::atLeastOneString(**string** $haystack, **array** $needles)** - -Return true if at least one needle is contained in the haystack - -**div::delDefault(**mixed** $search)** - -Remove a default replacement - -**div::delDefaultByVar(**string** $var, **mixed** $search)** - -Remove a default replacement for specific variable - -**div::delGlobal(**string** $var)** - -Remove a global var - -**div::disableSystemVar(**string** $var)** - -Disable [system var](https://divengine.org/documentation/div-php-template-engine/methodss-reference#system-vars) for performance - -**div::enableSystemVar(**string** $var)** - -Enable [system var](https://divengine.org/documentation/div-php-template-engine/methodss-reference#system-vars) for utility - -**div::error(**string** $errmsg, **string** $level = 'WARNING')** - -Show error and die - -**div::fileExists(**string** $filename)** - -Secure 'file exists' method - -**div::getLastKeyOfArray(**array** $arr)** - -Return the last key of array or null if not exists - -**div::getCountOfParagraphs(**string** $text)** - -Count a number of paragraphs in a text - -**div::getCountOfSentences(**string** $text)** - -Count a number of sentences in a text - -**div::getCountOfWords(**string** $text)** - -Count a number of words in a text - -**div::getDefault(**mixed** $value)** - -Return a default replacement of value - -**div::getDefaultByVar(**string** $var, **mixed** $value)** - -Return a default replacement of value by var - -**div::getSystemData()** - -Return the [loaded data from the system](https://divengine.org/documentation/div-php-template-engine/methodss-reference#system-vars) - -**div::getVersion()** - -Return current engine version string - -**div::getVarsFromCode(**string** $code)** - -Return a list of vars from PHP code - -**div::haveVarsThisCode(**string** $code)** - -Return true if the PHP code have any var - -**div::htmlToText(**string** $html, **integer** $width = 50)** - -Convert HTML to plain and formated text - -**div::isArrayOfArray(**array** $arr)** - -Return true if $arr is array of array - -**div::isArrayOfObjects(**array** $arr)** - -Return true if $arr is array of objects - -**div::isCli()** - -Return true if the script was executed in the CLI enviroment - -**div::isNumericList(**array** $arr)** - -Return true if $arr is array of numbers - -**div::isValidExpression(**string** $code)** - -Check if code is a valid expression - -**div::isDir(**string** $dirname)** - -Secure 'is_dir' method - -**div::isString(**mixed** $valur)** - -Secure 'is_string' method - -**div::jsonDecode(**string** $str)** - -JSON Decode - -**div::jsonEncode(**mixed** $data)** - -JSON Encode - -**div::log(**string** $msg, **string** $level = ' ')** - -Write a message in the log file - -**div::logOn(**string** $logfile)** - -Activate the debug mode for Div and write the logs into $logfile. - -**div::mixedBool(**mixed** $value)** - -Return any value as a boolean - -**div::setAllowedFunction({$src} $funcname)** - -Allow a function for the [formulas](https://divengine.org/documentation/div-php-template-engine/methodss-reference#formulas) - -**div::setDefault(**mixed** $search, **mixed** $replace)** - -Add or set a default replacement of value - -**div::setDefaultByVar(**string** $var, **mixed** $search, **mixed** $replace, **bool** $update = true)** - -Add or set a default replacement of value for a specific var - -**div::unsetAllowedFunction(**string** $funcname)** - -Unset the allowed function - -**div::utf162utf8(**string** $utf16)** - -Convert string from UTF16 to UTF18 - -**div::varExists(**string** \$var, **mixed** &\$items = null)** - -Return true if var exists in the template's items recursively - -## Instance methods - -**div->addLiteral(**string** $var)** - -Mark one or more template variables as literal (skip further parsing). Accepts a space- or comma-separated list. - -**div->getLiterals()** - -Return the current literal vars map for this instance diff --git a/docs/Noteworthy Issues.md b/docs/Noteworthy Issues.md deleted file mode 100644 index fc41be8..0000000 --- a/docs/Noteworthy Issues.md +++ /dev/null @@ -1,3 +0,0 @@ -Explore the following list of noteworthy issues that have been addressed or are currently under discussion. These issues are significant and have played a crucial role in shaping the development and improvement of the project. Click on the links below to dive into the details of each issue - -- https://github.com/divengine/div/issues/7 diff --git a/docs/README.md b/docs/README.md index 1ad0b2e..bc52c9f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,9 +3,13 @@ > Content may be incomplete, subject to change, or restructured as the Div engine evolves. > Please use with caution and check back regularly for updates. +# Overview + Requirements: PHP >= 8.0. -**div** is a [template engine](https://en.wikipedia.org/wiki/Template_processor) and [code generator tool](https://en.wikipedia.org/wiki/Code_generation_%28compiler%29) tool written in [PHP](http://php.net/) and developed since 2011, designed to optimize collaboration between developers and designers through generative programming, model-driven architecture, and meta-programming. This engine not only facilitates the separation of labor between roles but also allows for deep customization through the creation of tailored template [dialects](https://dialector.divengine.org) to meet specific project needs. +Div is a template engine and code generator written in PHP. It is designed to separate presentation concerns from data and behavior, and to support model-driven and generative workflows. The engine can adapt its syntax through dialects while preserving a canonical internal representation for parsing and transformation. + +## Processing pipeline ```mermaid flowchart TD @@ -44,7 +48,7 @@ flowchart TD F -- No --> G["Output: Final text (HTML/code/etc.)"] ``` -One of the most distinctive features of **div** is its ability to **recursively process templates until there is no more code to process**, effectively avoiding infinite loops and enabling complex, multi-step transformations. This translates into exceptional flexibility for dynamically generating content or code based on the data and logic specified in the templates. +## Convergence and recursion ```mermaid flowchart LR @@ -59,7 +63,7 @@ flowchart LR E -- "No" --> I["Convergence reached: return src"] ``` -Additionally, **div** supports the creation of custom template dialects, allowing users to define and modify the syntax to better suit different programming environments or to enhance code readability and maintenance. For example, it's possible to configure a dialect that ensures templates remain as valid XML, facilitating integration with other systems and technologies that utilize XML. +## Dialects ```mermaid flowchart LR @@ -79,7 +83,7 @@ flowchart LR G -- "No" --> H["Final output (HTML/code/etc.)"] ``` -## Scopes and sub-instances (loop render parallel/serial) +## Loop scope and sub-instances ```mermaid sequenceDiagram @@ -99,76 +103,32 @@ sequenceDiagram E-->>E: Continue global multipass parse ``` -This engine is the cornerstone of [Divengine Software Solutions](https://divengine.com) and adheres to the philosophy of *"build more with less"* and *"divide the problem, not the people."* **div** proposes code generation based on templates that adhere to clear rules: the model contains all information about what is to be accomplished; the templates define the expected outcomes; and the engine, acting as a black box, takes care of the execution. - -Basic operations include: - -- **Compile**: Combine a template with models and save the result. -- **Transform**: Convert one model to another, reusing the compile operation. -- **Compose**: Integrate different results using the engine and other tools. - -```mermaid -classDiagram - class Block { - +delimiters - +rules() - +examples() - } - class RigidBlock { - +prefix - +suffix - +whitespace: significant - } - class SimpleBlock { - +begin - +end - +whitespace: flexible - } - class KeywordBlock { - +begin_prefix - +keyword - +begin_suffix - +end_prefix - +keyword - +end_suffix - } - class NoKeywordBlock { - +begin_prefix - +begin_suffix - +end - +closing without repeating keyword - } - Block <|-- RigidBlock - Block <|-- SimpleBlock - Block <|-- KeywordBlock - Block <|-- NoKeywordBlock - -``` +## Core operations -With **div**, developers and designers can avoid repetitive tasks, scale projects based on models, migrate projects to different technologies, and expand applications to other platforms and devices, all while improving application performance and enabling non-technical people to participate in the project's development. +- Compile: combine a template with a model and save the result. +- Transform: convert one model into another by reusing compilation. +- Compose: assemble multiple outputs into a final artifact. -## Install +## Installation ```bash composer require divengine/div ``` + ## Upgrade ```bash composer upgrade ``` -[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=divengine&repo=div&show_owner=true&rand=23)](https://github.com/anuraghazra/github-readme-stats) - -[[Introduction to Div PHP Template Engine]] -[[The div class]] -[[The best practices]] -[[Template Engine Features]] -[[Method's reference]] -[[Mechanisms]] -[[Appendixes]] +## Documentation map -Se also the [[CHANGELOG]] and the [[FUTURE]] or this project. +- [[01 Introduction]] +- [[02 Template Features]] +- [[03 PHP Features]] +- [[04 Mechanisms]] +- [[05 Appendixes]] +See also [CHANGELOG](../releases/CHANGELOG.md). #templates diff --git a/docs/Template Engine Features.md b/docs/Template Engine Features.md deleted file mode 100644 index 063326b..0000000 --- a/docs/Template Engine Features.md +++ /dev/null @@ -1,31 +0,0 @@ -[[Variables (information, content...)]] -[[Simple replacements]] -[[Special replacements]] -[[Variable's modifiers]] -[[Data formats]] -[[Formulas]] -[[Ignored parts (escaping Div parsing)]] -[[Comments]] -[[Capsules]] -[[HTML to plain text]] -[[Lists (loops)]] -[[Iterations]] -[[Conditional parts]] -[[Conditions]] -[[Global vars]] -[[Aggregate functions]] -[[Dialects]] -[[Friendly tags]] -[[Sub-parsers]] -[[Including another templates]] -[[Default replacements]] -[[Including pre-processed templates]] -[[Locations]] -[[Macros]] -[[Multi replacements]] -[[Object Oriented Programming]] -[[Strip or clean the resulting code]] -[[System vars]] -[[Template's documentation]] -[[Template's properties]] -[[Template's variables]] diff --git a/docs/The best practices.md b/docs/The best practices.md deleted file mode 100644 index 22be72f..0000000 --- a/docs/The best practices.md +++ /dev/null @@ -1,3 +0,0 @@ -1. **The design should not "guess" the content**: The developers in occasions give this task to the template, and they obtain content using the possibilities of the language of templates, when in fact this it is the programmer's task. For example, it is an error to calculate in the template the amounts of the products of an invoice and the total amount, although this it can seem an example of the use of [**aggregate functions**](https://divengine.org/docs/div-php-template-engine/best-practices#aggregate-functions "Go to section related to: aggregate functions"). The language of templates is not conceived to obtain the lacking information, but to make a good design. -2. **The design should be very wrapped to the content and vice versa**: Try to balance the content built in the programming, with the content manipulated in the template, so that it doesn't have more than enough content, which the motor has to discard, neither have more than enough template code, which the motor also ends ignoring. -3. **Divide the design as much as it is possible and not so much that it is absurd**: Try to build the templates so that they complete the smallest quantity in objectives and that they are the smallest possible, and therefore reusable. Don't build big templates with many conditions where most is discarded. The developers sometimes mix the templates some with other, to have everything in a file and this diminishes the performance of the project. For example, it is not good practice to have two templates in one, prepared for two different contents separated by a since condition this implies to have another decision variable. If you have not found another solution, divide the template in two parts, make a third and use the inclusions or the pre-processed templates. But remember, it is not good practice to have an isolated template that it is included and always for one template, and therefore it is not reused neither conditionally loaded. \ No newline at end of file diff --git a/docs/The div class.md b/docs/The div class.md deleted file mode 100644 index 098456d..0000000 --- a/docs/The div class.md +++ /dev/null @@ -1,61 +0,0 @@ -All implementation of Div is the **div** class and different forms exist of using it. **If you have another class named "div", you can rename the div class.** - -**First, include the div.php file:** - -```php - 'Peter' -]); -``` - -**Variant 2: First instance, then show** - -```php - -$t = new div('Hello {$name}', ['name' => 'Peter']); - -echo $t; /* or $t->show(); */ -``` - -**Variant 3: The template in external file** - -```php - -/* The file index.tpl contain the template code */ - -echo new div('index.tpl', ['name' => 'Peter']); -``` - -**Variant 4: The data as JSON code** - -```php - -echo new div('Hello {$name}', '{name: "Peter"}'); - -``` - -**Variant 5: The data in JSON file** - -```php -/* The file index.json contain the data as JSON code */ - -echo new div('index.tpl', 'index.json'); -``` - -[[Ignore specific variables (the third parameter of constructor)]] \ No newline at end of file diff --git a/docs/book-order.txt b/docs/book-order.txt index 90c9ff2..ea32014 100644 --- a/docs/book-order.txt +++ b/docs/book-order.txt @@ -1,63 +1,68 @@ # Book order for PDF build (paths are repo-relative) docs/README.md -docs/Div PHP Template Engine.md -docs/Introduction to Div PHP Template Engine.md -docs/Introduction/Goals.md -docs/Introduction/Reasons.md -docs/Introduction/Possibilities for the designer.md -docs/Introduction/Possibilities for the programmer.md -docs/The div class.md -docs/The best practices.md -docs/Template Engine Features.md -docs/Features/Understanding the syntax.md -docs/Features/Variables (information, content...).md -docs/Features/Simple replacements.md -docs/Features/Special replacements.md -docs/Features/Variable's modifiers.md -docs/Features/Multiple variable's modifiers.md -docs/Features/String's dissection.md -docs/Features/Data formats.md -docs/Features/Formulas.md -docs/Features/Lists (loops).md -docs/Features/Dynamic vars inside a loop.md -docs/Features/Iterations.md -docs/Features/Conditional parts.md -docs/Features/Conditions.md -docs/Features/Default replacements.md -docs/Features/Default replacement for a variable.md -docs/Features/Multi replacements.md -docs/Features/Capsules.md -docs/Features/Locations.md -docs/Features/Friendly tags.md -docs/Features/Comments.md -docs/Features/Ignored parts (escaping Div parsing).md -docs/Features/Strip or clean the resulting code.md -docs/Features/HTML to plain text.md -docs/Features/Global vars.md -docs/Features/Aggregate functions.md -docs/Features/Macros.md -docs/Features/Sub-parsers.md -docs/Features/Pre-defined sub-parsers.md -docs/Features/Sub-parser's events.md -docs/Features/System vars.md -docs/Features/Template's variables.md -docs/Features/Template's properties.md -docs/Features/Template's documentation.md -docs/Features/Including another templates.md -docs/Features/Including pre-processed templates.md -docs/Features/Dialects.md -docs/Features/Multiple dialects.md -docs/Features/Dialect translator.md -docs/Features/Custom modifiers.md -docs/Features/Object Oriented Programming.md -docs/Features/Content like an object (intelligent data).md -docs/Features/Hooks.md -docs/Features/The __toString magic method.md -docs/Method's reference.md -docs/Mechanisms.md -docs/Noteworthy Issues.md -docs/Ignore specific variables (the third parameter of constructor).md -docs/Appendixes.md -docs/Appendixes/Appendix A - Allowed PHP functions.md -docs/Appendixes/Appendix B - Comparison of syntax of Smarty and Div.md -docs/FUTURE.md +docs/01 Introduction.md +docs/01.01 Scope and purpose.md +docs/01.02 Engine behavior.md +docs/01.03 Dialect system.md +docs/01.04 Core operations.md +docs/01.05 Install.md +docs/01.06 Upgrade.md +docs/01.07 Related topics.md +docs/01.09 Goals.md +docs/01.10 Reasons.md +docs/01.13 The div class.md +docs/01.14 The best practices.md +docs/02 Template Features.md +docs/02.01 Understanding the syntax.md +docs/02.02 Variables (information, content...).md +docs/02.03 Simple replacements.md +docs/02.04 Special replacements.md +docs/02.05 Variable's modifiers.md +docs/02.06 Multiple variable's modifiers.md +docs/02.07 String's dissection.md +docs/02.08 Data formats.md +docs/02.09 Formulas.md +docs/02.10 Lists (loops).md +docs/02.11 Dynamic vars inside a loop.md +docs/02.12 Iterations.md +docs/02.13 Conditional parts.md +docs/02.14 Conditions.md +docs/02.15 Default replacements.md +docs/02.16 Default replacement for a variable.md +docs/02.17 Multi replacements.md +docs/02.18 Capsules.md +docs/02.19 Locations.md +docs/02.20 Friendly tags.md +docs/02.21 Comments.md +docs/02.22 Ignored parts (escaping Div parsing).md +docs/02.23 Strip or clean the resulting code.md +docs/02.24 HTML to plain text.md +docs/02.25 Global vars.md +docs/02.26 Aggregate functions.md +docs/02.27 Macros.md +docs/02.28 Sub-parsers.md +docs/02.29 Pre-defined sub-parsers.md +docs/02.30 Sub-parser's events.md +docs/02.31 System vars.md +docs/02.32 Template's variables.md +docs/02.33 Template's properties.md +docs/02.34 Template's documentation.md +docs/02.35 Including another templates.md +docs/02.36 Including pre-processed templates.md +docs/02.37 Dialects.md +docs/02.38 Multiple dialects.md +docs/02.39 Dialect translator.md +docs/02.40 Custom modifiers.md +docs/02.41 Object Oriented Programming.md +docs/02.42 Content like an object (intelligent data).md +docs/02.43 Hooks.md +docs/02.44 The __toString magic method.md +docs/02.45 Ignore specific variables (the third parameter of constructor).md +docs/03 PHP Features.md +docs/04 Mechanisms.md +docs/04.01 Components.md +docs/04.02 Recursion.md +docs/04.03 Templates inheritance.md +docs/05 Appendixes.md +docs/05.01 Appendix A - Allowed PHP functions.md +docs/05.02 Appendix B - Comparison of syntax of Smarty and Div.md diff --git a/docs/ChangeLog/CHANGELOG.md b/releases/CHANGELOG.md similarity index 100% rename from docs/ChangeLog/CHANGELOG.md rename to releases/CHANGELOG.md diff --git a/docs/ChangeLog/releases/README.md b/releases/README.md similarity index 100% rename from docs/ChangeLog/releases/README.md rename to releases/README.md diff --git a/docs/ChangeLog/releases/v6.1.2.md b/releases/v6.1.2.md similarity index 97% rename from docs/ChangeLog/releases/v6.1.2.md rename to releases/v6.1.2.md index f34b518..91fe058 100644 --- a/docs/ChangeLog/releases/v6.1.2.md +++ b/releases/v6.1.2.md @@ -29,7 +29,7 @@ This release focuses on project robustness and delivery quality. It adds a compr - [Add comprehensive test suite](https://github.com/divengine/div/commit/2784e0cb11ab46b4d9728e15d45fb1eee6dc0db0) - [Add initial README documentation for Div template engine](https://github.com/divengine/div/commit/86343cab39e88905704a2ef73965b8e9289d0b70) - [Add comprehensive documentation for Div PHP Template Engine features and usage](https://github.com/divengine/div/commit/bfad4ad2b67a84eb77063e4b1084eddeaca73208) -- [Update README.md](https://github.com/divengine/div/commit/18c545b49b0398366990448d4fe5715134ec3f43) +- [Update 01 README.md](https://github.com/divengine/div/commit/18c545b49b0398366990448d4fe5715134ec3f43) - [Fix class reference in div method for improved consistency](https://github.com/divengine/div/commit/6a90d5534ce5056e9d3e06fcd695f93b5c3e056b) - [Refactor div class methods for improved type handling and consistency](https://github.com/divengine/div/commit/467bc039c90d8e0ccff06a68f2065395f19dcd57) - [Update documentation for Div template engine PHP compatibility](https://github.com/divengine/div/commit/93201870658687d289d2c8cde8f845fe7dfe4638) diff --git a/docs/ChangeLog/releases/v6.1.3.md b/releases/v6.1.3.md similarity index 100% rename from docs/ChangeLog/releases/v6.1.3.md rename to releases/v6.1.3.md diff --git a/scripts/generate_release_notes.py b/scripts/generate_release_notes.py index 385afea..0c872da 100644 --- a/scripts/generate_release_notes.py +++ b/scripts/generate_release_notes.py @@ -42,7 +42,7 @@ def parse_version(value: str): def list_release_note_versions(): - releases_dir = ROOT / "docs" / "ChangeLog" / "releases" + releases_dir = ROOT / "releases" if not releases_dir.is_dir(): return [] versions = [] @@ -76,7 +76,7 @@ def get_base_from_previous_notes(version_tuple): if not version_tuple: return None filename = f"v{format_version(version_tuple)}.md" - path = ROOT / "docs" / "ChangeLog" / "releases" / filename + path = ROOT / "releases" / filename if not path.is_file(): return None text = path.read_text(encoding="utf-8").replace("\r\n", "\n") @@ -164,7 +164,7 @@ def main(): parser.add_argument( "--output", default="", - help="Output file path. Defaults to docs/ChangeLog/releases/v.md", + help="Output file path. Defaults to releases/v.md", ) args = parser.parse_args() @@ -184,7 +184,7 @@ def main(): output = args.output.strip() if not output: - output = f"docs/ChangeLog/releases/v{version}.md" + output = f"releases/v{version}.md" out_path = (ROOT / output).resolve() out_path.parent.mkdir(parents=True, exist_ok=True) From ca34786a025838f841ad76632665f2a23ebfa04a Mon Sep 17 00:00:00 2001 From: rafageist Date: Sat, 7 Feb 2026 21:50:54 -0300 Subject: [PATCH 6/9] chore(release): update release notes for versions v1.1.0 to v6.1.3 --- .gitattributes | 14 ++++++++++++++ releases/v1.1.0.md | 9 +++++++++ releases/v1.2.0.md | 9 +++++++++ releases/v1.3.0.md | 11 +++++++++++ releases/v1.4.0.md | 10 ++++++++++ releases/v1.5.0.md | 11 +++++++++++ releases/v1.6.0.md | 9 +++++++++ releases/v1.7.0.md | 11 +++++++++++ releases/v1.8.0.md | 12 ++++++++++++ releases/v1.9.0.md | 16 ++++++++++++++++ releases/v2.0.0.md | 11 +++++++++++ releases/v2.1.0.md | 17 +++++++++++++++++ releases/v2.2.0.md | 18 ++++++++++++++++++ releases/v2.3.0.md | 11 +++++++++++ releases/v2.4.0.md | 11 +++++++++++ releases/v2.5.0.md | 12 ++++++++++++ releases/v2.6.0.md | 12 ++++++++++++ releases/v2.7.0.md | 11 +++++++++++ releases/v2.8.0.md | 13 +++++++++++++ releases/v2.9.0.md | 15 +++++++++++++++ releases/v3.0.0.md | 12 ++++++++++++ releases/v3.1.0.md | 12 ++++++++++++ releases/v3.2.0.md | 12 ++++++++++++ releases/v3.3.0.md | 9 +++++++++ releases/v3.4.0.md | 11 +++++++++++ releases/v3.5.0.md | 13 +++++++++++++ releases/v3.6.0.md | 11 +++++++++++ releases/v3.7.0.md | 19 +++++++++++++++++++ releases/v3.8.0.md | 9 +++++++++ releases/v3.9.0.md | 38 ++++++++++++++++++++++++++++++++++++++ releases/v4.0.0.md | 15 +++++++++++++++ releases/v4.1.0.md | 13 +++++++++++++ releases/v4.2.0.md | 18 ++++++++++++++++++ releases/v4.3.0.md | 17 +++++++++++++++++ releases/v4.4.0.md | 13 +++++++++++++ releases/v4.5.0.md | 41 +++++++++++++++++++++++++++++++++++++++++ releases/v4.6.0.md | 9 +++++++++ releases/v4.7.0.md | 11 +++++++++++ releases/v4.8.0.md | 14 ++++++++++++++ releases/v4.9.0.md | 11 +++++++++++ releases/v5.1.0.md | 37 +++++++++++++++++++++++++++++++++++++ releases/v5.1.1.md | 9 +++++++++ releases/v5.1.2.md | 11 +++++++++++ releases/v5.1.3.md | 10 ++++++++++ releases/v5.1.4.md | 9 +++++++++ releases/v5.1.5.md | 9 +++++++++ releases/v5.1.6.md | 9 +++++++++ releases/v6.0.0.md | 8 ++++++++ releases/v6.0.1.md | 8 ++++++++ releases/v6.1.0.md | 8 ++++++++ releases/v6.1.1.md | 8 ++++++++ releases/v6.1.3.md | 5 ++++- 52 files changed, 681 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 releases/v1.1.0.md create mode 100644 releases/v1.2.0.md create mode 100644 releases/v1.3.0.md create mode 100644 releases/v1.4.0.md create mode 100644 releases/v1.5.0.md create mode 100644 releases/v1.6.0.md create mode 100644 releases/v1.7.0.md create mode 100644 releases/v1.8.0.md create mode 100644 releases/v1.9.0.md create mode 100644 releases/v2.0.0.md create mode 100644 releases/v2.1.0.md create mode 100644 releases/v2.2.0.md create mode 100644 releases/v2.3.0.md create mode 100644 releases/v2.4.0.md create mode 100644 releases/v2.5.0.md create mode 100644 releases/v2.6.0.md create mode 100644 releases/v2.7.0.md create mode 100644 releases/v2.8.0.md create mode 100644 releases/v2.9.0.md create mode 100644 releases/v3.0.0.md create mode 100644 releases/v3.1.0.md create mode 100644 releases/v3.2.0.md create mode 100644 releases/v3.3.0.md create mode 100644 releases/v3.4.0.md create mode 100644 releases/v3.5.0.md create mode 100644 releases/v3.6.0.md create mode 100644 releases/v3.7.0.md create mode 100644 releases/v3.8.0.md create mode 100644 releases/v3.9.0.md create mode 100644 releases/v4.0.0.md create mode 100644 releases/v4.1.0.md create mode 100644 releases/v4.2.0.md create mode 100644 releases/v4.3.0.md create mode 100644 releases/v4.4.0.md create mode 100644 releases/v4.5.0.md create mode 100644 releases/v4.6.0.md create mode 100644 releases/v4.7.0.md create mode 100644 releases/v4.8.0.md create mode 100644 releases/v4.9.0.md create mode 100644 releases/v5.1.0.md create mode 100644 releases/v5.1.1.md create mode 100644 releases/v5.1.2.md create mode 100644 releases/v5.1.3.md create mode 100644 releases/v5.1.4.md create mode 100644 releases/v5.1.5.md create mode 100644 releases/v5.1.6.md create mode 100644 releases/v6.0.0.md create mode 100644 releases/v6.0.1.md create mode 100644 releases/v6.1.0.md create mode 100644 releases/v6.1.1.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f1a8320 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +/.github export-ignore +/build export-ignore +/docs export-ignore +/releases export-ignore +/scripts export-ignore +/tests export-ignore +/vendor export-ignore + +/.gitignore export-ignore +/.phpunit.result.cache export-ignore +/composer.lock export-ignore +/phpstan-baseline.neon export-ignore +/phpstan.neon export-ignore +/phpunit.xml export-ignore diff --git a/releases/v1.1.0.md b/releases/v1.1.0.md new file mode 100644 index 0000000..1d165f4 --- /dev/null +++ b/releases/v1.1.0.md @@ -0,0 +1,9 @@ +# Release v1.1.0 +Date: 2012-03-15 + +## Description +This release includes: +- Fixed several issues of conditional parts. + +## Commits +- No commits found. diff --git a/releases/v1.2.0.md b/releases/v1.2.0.md new file mode 100644 index 0000000..2a30a48 --- /dev/null +++ b/releases/v1.2.0.md @@ -0,0 +1,9 @@ +# Release v1.2.0 +Date: 2012-03-22 + +## Description +This release includes: +- The @break@ mark Add break mark for breaking the loops. The position of break mark in the block are relevant. + +## Commits +- No commits found. diff --git a/releases/v1.3.0.md b/releases/v1.3.0.md new file mode 100644 index 0000000..86ba18a --- /dev/null +++ b/releases/v1.3.0.md @@ -0,0 +1,11 @@ +# Release v1.3.0 +Date: 2012-03-23 + +## Description +This release includes: +- Prevented the errors of formulas. +- Prevented the errors of conditions. +- Fixed important bug of @else@ mark of conditions into other conditions and conditionals. + +## Commits +- No commits found. diff --git a/releases/v1.4.0.md b/releases/v1.4.0.md new file mode 100644 index 0000000..2d96ff0 --- /dev/null +++ b/releases/v1.4.0.md @@ -0,0 +1,10 @@ +# Release v1.4.0 +Date: 2012-03-28 + +## Description +This release includes: +- Fixed bugs of blocks of conditions. +- Added new feature named ITERATIONS. + +## Commits +- No commits found. diff --git a/releases/v1.5.0.md b/releases/v1.5.0.md new file mode 100644 index 0000000..a887fd6 --- /dev/null +++ b/releases/v1.5.0.md @@ -0,0 +1,11 @@ +# Release v1.5.0 +Date: 2012-03-30 + +## Description +This release includes: +- The algorithm was improved. Div is faster now. +- Fixed bugs. +- A new variable's modifier was added to encode URL. + +## Commits +- No commits found. diff --git a/releases/v1.6.0.md b/releases/v1.6.0.md new file mode 100644 index 0000000..539f9e2 --- /dev/null +++ b/releases/v1.6.0.md @@ -0,0 +1,9 @@ +# Release v1.6.0 +Date: 2012-04-02 + +## Description +This release includes: +- In version 1.5 to improve the algorithms made a mistake and lost functionality of the iterations of Lists, which is the priority of an item variable under way, with the same name of a variable outside the loop. Now in version 1.6 is working again just as quickly. + +## Commits +- No commits found. diff --git a/releases/v1.7.0.md b/releases/v1.7.0.md new file mode 100644 index 0000000..b15de4f --- /dev/null +++ b/releases/v1.7.0.md @@ -0,0 +1,11 @@ +# Release v1.7.0 +Date: 2012-04-05 + +## Description +This release includes: +- Recovering a lost functionality. In version 1.5 to improve the algorithms made a mistake and break functionality of the Formulas. Now in version 1.7 is working again just as quickly. +- Added new functionality for programmers in the constructor of div class with new parameter: IGNORE SOME VARIABLES. Example. +- Prevented a bugs with length two first parameters as filenames, in the div constructor. + +## Commits +- No commits found. diff --git a/releases/v1.8.0.md b/releases/v1.8.0.md new file mode 100644 index 0000000..1c36cee --- /dev/null +++ b/releases/v1.8.0.md @@ -0,0 +1,12 @@ +# Release v1.8.0 +Date: 2012-04-07 + +## Description +This release includes: +- Recovering a lost functionality. In version 1.5 to make the algorithms more efficient we made a mistake and break functionality of the clean the orphan parts. Now in version 1.8 is working again just as quickly. +- Fixed some grave bugs. +- If a var contain an object, {$var} will be replace with the count of properties. +- Sub matches: now you can write ($var:0,20} or {$var:20} to replace this mark with substr($var, 0, 20);. + +## Commits +- No commits found. diff --git a/releases/v1.9.0.md b/releases/v1.9.0.md new file mode 100644 index 0000000..590bdec --- /dev/null +++ b/releases/v1.9.0.md @@ -0,0 +1,16 @@ +# Release v1.9.0 +Date: 2012-04-09 + +## Description +This release includes: +- Fixed some grave bugs of iterations functionality and other improvements. +- Custom item variable for lists and mark =>. +- Custom item variable for iterations: you now can specify the iteration variable. +- Nested iterations. The following example... +- New variable for iterations and lists's cycle. +- $_list, that it contains the list's name. +- $_item, that it contains the list's item. +- $_key, that it contains the item's key. + +## Commits +- No commits found. diff --git a/releases/v2.0.0.md b/releases/v2.0.0.md new file mode 100644 index 0000000..058c9f0 --- /dev/null +++ b/releases/v2.0.0.md @@ -0,0 +1,11 @@ +# Release v2.0.0 +Date: 2012-04-14 + +## Description +This release includes: +- Added a new variable for the cycles: $_order, that is $_index + 1. The index begins with 0. The order begins with 1. This is useful when you need to build an ordered list without
    tag and reused item template. +- Added new variable's modifiers: html and br. +- Fixed bugs of recursion and recovered the high priority of variables into the cycles. + +## Commits +- No commits found. diff --git a/releases/v2.1.0.md b/releases/v2.1.0.md new file mode 100644 index 0000000..3640cfb --- /dev/null +++ b/releases/v2.1.0.md @@ -0,0 +1,17 @@ +# Release v2.1.0 +Date: 2012-05-08 + +## Description +This release includes: +- Changed mixedBool() and parseMatch() methods for trim the string values. +- Enabled two new properties for PHP developers: $__src and $__packages. +- If you want that the names of the files have a prefix, specify it in constant PACKAGES or in the property $__packages of a class that extends the div. See. +- Added new constant DIV_DEFAULT_TPL_FILE_EXT for define a template file extension. You can define this constant BEFORE include the div.php script. The default value for this constant is the string "tpl". +- Added new constant DIV_DEFAULT_DATA_FILE_EXT for define a data file extension. You can define this constant BEFORE include the div.php script. The default value for this constant is the string "json". +- Implement the show() method. +- If you don't pass the value of $src for the div class constructor, then Div assumes that $src is the name of the class :). +- Enabled the div extends for OOP in the programmer side. The name of the properties should not begin with __ (double underscore). See the follow example. +- Added a new functionality: pre-processed parts. + +## Commits +- No commits found. diff --git a/releases/v2.2.0.md b/releases/v2.2.0.md new file mode 100644 index 0000000..df34065 --- /dev/null +++ b/releases/v2.2.0.md @@ -0,0 +1,18 @@ +# Release v2.2.0 +Date: 2012-05-14 + +## Description +This release includes: +- Added aggregate functions for the lists: sum, avg, min, max, and the default count function. +- Added a new constant constant DIV_CLASS_NAME for define the name of de superclass of div. Now the programmer can change the name of the div class to avoid possible collisions the class's names of his application. +- Added a new functionality: default replacements by variable. +- Now the definition of data in templates is similar to set a global var in the programmer side and you can re-refine this data every time in the template and now the sequence of the operations is not ignored. The variables have arrived. +- Fixed bugs. +- Added new functionality: capsules!, with the symbol of Div logo!.... of course. +- Added new feature for iterations functionality: now you can specify a STEP for iteration. +- Another way to define the iteration var with high priority. Now the follow templates are similars. +- New functionality: assign to design vars the result of method! If the programmer implemented a class that inherits of div, then the designer can use the methods of this class. +- Fixed bugs. + +## Commits +- No commits found. diff --git a/releases/v2.3.0.md b/releases/v2.3.0.md new file mode 100644 index 0000000..55530a8 --- /dev/null +++ b/releases/v2.3.0.md @@ -0,0 +1,11 @@ +# Release v2.3.0 +Date: 2012-05-22 + +## Description +This release includes: +- New: Allowed functions. Now the programmer can enable functions of or written in PHP so that the designer can use them in the templates. +- New: Add new item to list or set a property of object. +- New: Allow to asign a program var to a template var. + +## Commits +- No commits found. diff --git a/releases/v2.4.0.md b/releases/v2.4.0.md new file mode 100644 index 0000000..2e06933 --- /dev/null +++ b/releases/v2.4.0.md @@ -0,0 +1,11 @@ +# Release v2.4.0 +Date: 2012-06-08 + +## Description +This release includes: +- Added new functionality: show the teaser of a text. Similar to get a substring of text. +- Fixed bugs. +- Added new functionality: text wrap. + +## Commits +- No commits found. diff --git a/releases/v2.5.0.md b/releases/v2.5.0.md new file mode 100644 index 0000000..e0c1801 --- /dev/null +++ b/releases/v2.5.0.md @@ -0,0 +1,12 @@ +# Release v2.5.0 +Date: 2012-06-30 + +## Description +This release includes: +- Fixed bugs. +- Added new functionality: html to text. +- Fixed bugs. +- Added new funcionality for log: Save the steps of the parser into log file. + +## Commits +- No commits found. diff --git a/releases/v2.6.0.md b/releases/v2.6.0.md new file mode 100644 index 0000000..c23ee21 --- /dev/null +++ b/releases/v2.6.0.md @@ -0,0 +1,12 @@ +# Release v2.6.0 +Date: 2012-07-26 + +## Description +This release includes: +- Added new features for performance: enable and disable system var. +- Added new features for replacements: multiple replacements. +- Fixed bugs. +- Fixed bugs. + +## Commits +- No commits found. diff --git a/releases/v2.7.0.md b/releases/v2.7.0.md new file mode 100644 index 0000000..53548d2 --- /dev/null +++ b/releases/v2.7.0.md @@ -0,0 +1,11 @@ +# Release v2.7.0 +Date: 2012-08-03 + +## Description +This release includes: +- Fixed bugs. +- Added new feature for json encode. +- Fixed bugs. + +## Commits +- No commits found. diff --git a/releases/v2.8.0.md b/releases/v2.8.0.md new file mode 100644 index 0000000..355eefc --- /dev/null +++ b/releases/v2.8.0.md @@ -0,0 +1,13 @@ +# Release v2.8.0 +Date: 2012-08-16 + +## Description +This release includes: +- If you don't define a variable, the expression is FALSE. +- If you don't define a variable, the formula will be ignored. +- Freed of the function json_encode of PHP and corrected some errors of this function. +- Added new feature: Relative paths for include and preprocessed templates. +- Changed the type of method of mixedBool from public to static. + +## Commits +- No commits found. diff --git a/releases/v2.9.0.md b/releases/v2.9.0.md new file mode 100644 index 0000000..842d39e --- /dev/null +++ b/releases/v2.9.0.md @@ -0,0 +1,15 @@ +# Release v2.9.0 +Date: 2012-09-02 + +## Description +This release includes: +- Changed the type of method of getSystemData from public to static. +- The algorithm of text summary was improved. +- New feature: IDE's friendly marks . +- Delete the DIV_CLASS_NAME constant: now is more simple to change the name of div class. Simply change the name of div class, no more. +- Fixed problem of template vars's scope. The inheritance mechanism is more simple now. +- Improvements to the template's vars. Now you can do this. +- Fixed bugs. + +## Commits +- No commits found. diff --git a/releases/v3.0.0.md b/releases/v3.0.0.md new file mode 100644 index 0000000..ac23fca --- /dev/null +++ b/releases/v3.0.0.md @@ -0,0 +1,12 @@ +# Release v3.0.0 +Date: 2012-11-04 + +## Description +This release includes: +- Fixed bugs of conditions into loops. +- Fixed important issue for matchs. Now work the follow example. +- Fixed some problems. +- Improved some mechanisms. + +## Commits +- No commits found. diff --git a/releases/v3.1.0.md b/releases/v3.1.0.md new file mode 100644 index 0000000..32faa9e --- /dev/null +++ b/releases/v3.1.0.md @@ -0,0 +1,12 @@ +# Release v3.1.0 +Date: 2012-11-21 + +## Description +This release includes: +- Allowed "intval" PHP function in formulas. +- Improved the algorithm of lists/loops/cycles. +- Detection of recursive inclusion as an error. +- Updated documentation. + +## Commits +- No commits found. diff --git a/releases/v3.2.0.md b/releases/v3.2.0.md new file mode 100644 index 0000000..49f3ccb --- /dev/null +++ b/releases/v3.2.0.md @@ -0,0 +1,12 @@ +# Release v3.2.0 +Date: 2013-02-04 + +## Description +This release includes: +- Improved date's values detection. +- Fixed a bug with {ignore} functionality. +- Added new vars for the iterations: $_previous and $_next. +- Algorithm improved: 95% more faster. + +## Commits +- No commits found. diff --git a/releases/v3.3.0.md b/releases/v3.3.0.md new file mode 100644 index 0000000..a115326 --- /dev/null +++ b/releases/v3.3.0.md @@ -0,0 +1,9 @@ +# Release v3.3.0 +Date: 2013-02-15 + +## Description +This release includes: +- Fixed a critical bug: prevented infinite cycle. + +## Commits +- No commits found. diff --git a/releases/v3.4.0.md b/releases/v3.4.0.md new file mode 100644 index 0000000..9b4667f --- /dev/null +++ b/releases/v3.4.0.md @@ -0,0 +1,11 @@ +# Release v3.4.0 +Date: 2013-02-19 + +## Description +This release includes: +- Added new feature: Multiple variable's modifiers. +- The documentation was updated. +- Improved detection of infinite loops on includes and replacements. + +## Commits +- No commits found. diff --git a/releases/v3.5.0.md b/releases/v3.5.0.md new file mode 100644 index 0000000..1f097f9 --- /dev/null +++ b/releases/v3.5.0.md @@ -0,0 +1,13 @@ +# Release v3.5.0 +Date: 2013-03-08 + +## Description +This release includes: +- New feature: @empty@ tag for list's blocks. +- New feature: locations. +- Improved the conditional parts: the first and last blank space are removed. +- Updated the documentation. +- Fixes some bugs of new features. + +## Commits +- No commits found. diff --git a/releases/v3.6.0.md b/releases/v3.6.0.md new file mode 100644 index 0000000..08bbc74 --- /dev/null +++ b/releases/v3.6.0.md @@ -0,0 +1,11 @@ +# Release v3.6.0 +Date: 2013-03-16 + +## Description +This release includes: +- Improved the detection of orphan conditional parts. +- Improved the feature "template vars". Now you can execute the "methods of information". +- Improved the access to object's public methods. + +## Commits +- No commits found. diff --git a/releases/v3.7.0.md b/releases/v3.7.0.md new file mode 100644 index 0000000..dad67eb --- /dev/null +++ b/releases/v3.7.0.md @@ -0,0 +1,19 @@ +# Release v3.7.0 +Date: 2013-03-30 + +## Description +This release includes: +- Added new feature for programmers: custom variable's modifier. +- Added new feature for programmers: the hooks!. The hooks are. +- Improved the setItem method. +- Added a new feature for programmers: the method changeTemplate(). +- Improved the show() method with a new parameter: specific template. +- Some functions of PHP are enabled in formulas and conditions. +- Added a new system var named: $div.ascii. This var contain the all chars of ASCII table. +- From version 3.6 Div maintains a policy regarding the use of objects: if an object has implemented the method __ toString then be treated as a character string. We are working to improve the policy and avoid unhappy. +- Improved the speed. +- Improved the options arround the __toString method of objects in 3 scopes. See the example below. +- Improved the interpretation of third parameter of the constructor as a string with the variables's names. + +## Commits +- No commits found. diff --git a/releases/v3.8.0.md b/releases/v3.8.0.md new file mode 100644 index 0000000..b0a8882 --- /dev/null +++ b/releases/v3.8.0.md @@ -0,0 +1,9 @@ +# Release v3.8.0 +Date: 2013-04-03 + +## Description +This release includes: +- Version 3.7 was released with a serious error that was corrected in the 3.8. + +## Commits +- No commits found. diff --git a/releases/v3.9.0.md b/releases/v3.9.0.md new file mode 100644 index 0000000..9e59899 --- /dev/null +++ b/releases/v3.9.0.md @@ -0,0 +1,38 @@ +# Release v3.9.0 +Date: 2013-05-18 + +## Description +This release includes: +- The scalar values as a complex values! What? +- Fixed some issues. +- New method div::isSring as a safe is_string(). +- If is a string return true. +- If is a object with __toString method return true. +- Bug fix of template variables when it use object's methods Now you can call a object's method with some ways. +- Bug fix of loops, prevent a recursion with var '_item' as object inside the same object. +- The order respect of template variables's manipulation was improved. +- The template variables's manipulation was improved. +- The method setItem and getItem was improved with detection of complex variable's names. +- Bug fix in the bodies of multi-replacements. +- Changed the name of method multiReplace by parseMultiReplace. +- Performance: work remembered! Now the engine can remember some actions from previous work and increase their speed. +- New feature: the macros. +- New feature: the custom sub-parsers. +- The interpretation of aggregate functions was improved. The next example work now. +- The interpretation of date format was improved. +- New static method anyToStr, for convert mixed value to string based on this rule. +- String is string. +- Boolean is "true" or "false". +- Number is "number". +- Object with __toString() is __toString(). +- Object without __toString() is array. +- Array is count(). +- Changed the type of unchangeable methods to "final". +- Enabled custom dialect for developers. +- New static method isValidCurrentDialect, for detect error in the definition of current dialect, based on this rule. +- Some tags are required, like as, prefixes, suffixes, beginnings and ends. +- Some tags must be unique, like as, modifiers, else, break, empty, ... +- Created a tool to build dialects. + +## Commits +- No commits found. diff --git a/releases/v4.0.0.md b/releases/v4.0.0.md new file mode 100644 index 0000000..953148c --- /dev/null +++ b/releases/v4.0.0.md @@ -0,0 +1,15 @@ +# Release v4.0.0 +Date: 2013-05-27 + +## Description +This release includes: +- Fixed some bugs in locations and conditional parts. +- Created a translator of dialects. Div now have 2 new public methods. +- New feature: template properties. Now you can specify some properties in the template's code, for example, the dialect of the current template. +- New feature: predefined subparsers. Div provide pre-defined sub-parsers, for example, This means that a new instance of div will be created, similar to the loops and the capsules. Other predefined subparsers will be developed in future releases. +- New feature: sub-parser's events. Now in the templates's code you can specify when a sub-parser will be executed: beforeParse, afterInclude or afterParse. Example. +- Improved the conditional parts detection. +- Changed to private some div's properties. + +## Commits +- No commits found. diff --git a/releases/v4.1.0.md b/releases/v4.1.0.md new file mode 100644 index 0000000..5892a62 --- /dev/null +++ b/releases/v4.1.0.md @@ -0,0 +1,13 @@ +# Release v4.1.0 +Date: 2013-05-30 + +## Description +This release includes: +- Fixed and improve the algorithm of div::getVarValue() method. +- Fixed the detection of conditional parts. +- Test new version. +- Minor bugs was fixed. +- Improved the detection of date formats. + +## Commits +- No commits found. diff --git a/releases/v4.2.0.md b/releases/v4.2.0.md new file mode 100644 index 0000000..01252b0 --- /dev/null +++ b/releases/v4.2.0.md @@ -0,0 +1,18 @@ +# Release v4.2.0 +Date: 2013-06-08 + +## Description +This release includes: +- Improved the getRanges() algorithm to cover more cases. Div now continues searching ranges after unclosed tags. +- Improved the parser for ignored parts. +- Improved the parser for includes. +- New feature: template documentation. Now in the comments you can document the template. The documentation sections use @ as a prefix. +- Fixed the getRanges() algorithm. +- Fixed the parser for macros. +- Added a new sub-parser's event: afterReplace. +- Fixed and improved the translator. +- Fixed and improved the parser. +- Improved template documentation. + +## Commits +- No commits found. diff --git a/releases/v4.3.0.md b/releases/v4.3.0.md new file mode 100644 index 0000000..f275f77 --- /dev/null +++ b/releases/v4.3.0.md @@ -0,0 +1,17 @@ +# Release v4.3.0 +Date: 2013-06-15 + +## Description +This release includes: +- Improved the parser for template's vars: If the value is not valid JSON, it will be considered as a template and will be parsed before decoding. +- Improved the parser for template's variables. Was improved the detection of assignment of variables in any part of the. +- Improved relative include/preprocessed templates. Now the next example works. +- Improved template's variables assignment. Now the next example works. +- Improved the variables's scope: Now the next example works. +- Integration with Google Chrome/Console and Mozilla Firefox/Firebug plugins. Now the engine's messages will be appear in this browsers's features. +- Improved detection of infinite loops in recursive replacements. +- Improved parser and bugs fixes: if foo not existed, widget waits forever. Now the next example works. +- Improved logs's system. + +## Commits +- No commits found. diff --git a/releases/v4.4.0.md b/releases/v4.4.0.md new file mode 100644 index 0000000..05b96df --- /dev/null +++ b/releases/v4.4.0.md @@ -0,0 +1,13 @@ +# Release v4.4.0 +Date: 2013-07-27 + +## Description +This release includes: +- Improved the modifier "escape single quotes" (\') to "escape single/double quotes" (\"). +- Improved default documentation's template. +- Bug fix the translator. +- New feature: Multi template sources (based on include_path PHP setting). +- Bug fixes. + +## Commits +- No commits found. diff --git a/releases/v4.5.0.md b/releases/v4.5.0.md new file mode 100644 index 0000000..6432793 --- /dev/null +++ b/releases/v4.5.0.md @@ -0,0 +1,41 @@ +# Release v4.5.0 +Date: 2014-12-01 + +## Description +This release includes: +- Decrease of priority in parser's specialchars. +- An important bug was fixed: the memory in the loops. +- Bug fix: div::getFileContents(). +- Improved global design vars in loops and capsules. +- Bug fix: div::fileExists and wrong include paths calculation. +- Memory fixed. +- Some bug fixes. +- Added new important security feature: setup literals items/vars, for prevent injections. +- Allowed is_array PHP function in macros. +- New method for add literal vars in PHP: div::addLiteral();. +- Fixed macros parsing when a previous template var never match. +- Fixed the memory in the loops. +- Security fix: prevent obtrusive code in method calls. Now next code doesn't work. +- New feature for preprocessed templates: specific data. +- Bug fix: Parse pre-processed templates with all items/vars (Div doesn't know the future). +- Bug fix: Adding items to array in templates. +- Bug fix: Don't set item var as design var in div::parseData();. +- Bigfix: Save sections of loops and capsules when makeItAgain(); (Div doesn't know the future). +- Big fix: Set the priority to inline data in pre-processed templates above global design vars. +- Bug fixed and improved - Parsing orphan's parts while checksum not change. Do it because the orphans's parts stop the parser and the results are ugly. +- Bug fix: Parsing macros inside preprocessed templates. New argument $min_level for parse() method. +- Added new allowed functions in macros, formulas and expressions: array_keys get_object_vars is_object. +- Allowed T_BREAK token in macros for foreach and other loops. Then, the follow macro is an error. +- New feature: advanced options/params for includes. +- Bug fix: Preparing allowed methods before execute the macros. +- Bug fix in parsePreprocessed() when $pdata is null. +- Bug fix with number formats inside loops. +- Bug fix parseData() vs parseMatch() logical order. +- New setup var: div.clear_locations (= true by default). This means that the locations will be clear or not at the end (parse_level = 0). Then, the components are more flexible with **pre-processed templates**. +- Improved performance changing $vars with __temp['vars'] var in parseMacros(); because because get_defined_vars return also vars. +- Prevented infinite loops in div::cop();. +- Improved div::isValidPHPCode(). +- Some bug fixes. + +## Commits +- No commits found. diff --git a/releases/v4.6.0.md b/releases/v4.6.0.md new file mode 100644 index 0000000..cb6339f --- /dev/null +++ b/releases/v4.6.0.md @@ -0,0 +1,9 @@ +# Release v4.6.0 +Date: 2015-12-11 + +## Description +This release includes: +- Bug fix in div class constructor. + +## Commits +- No commits found. diff --git a/releases/v4.7.0.md b/releases/v4.7.0.md new file mode 100644 index 0000000..4ace15c --- /dev/null +++ b/releases/v4.7.0.md @@ -0,0 +1,11 @@ +# Release v4.7.0 +Date: 2015-12-19 + +## Description +This release includes: +- Some bug fixes, thanks to gracix and Takefumi Ota. +- Improved template's vars and OOP: now you can access to a public method of any object. +- Several tests. + +## Commits +- No commits found. diff --git a/releases/v4.8.0.md b/releases/v4.8.0.md new file mode 100644 index 0000000..d23fc40 --- /dev/null +++ b/releases/v4.8.0.md @@ -0,0 +1,14 @@ +# Release v4.8.0 +Date: 2016-10-10 + +## Description +This release includes: +- Added new feature for dialects: DIV_TAG_VAR_MEMBER_DELIMITER. This dialect's constant define a delimiter for variable's members. +- Improved dialect translator div::translateFrom. +- Some bug fixes. +- Updated documentation. +- Review example. +- Several tests. + +## Commits +- No commits found. diff --git a/releases/v4.9.0.md b/releases/v4.9.0.md new file mode 100644 index 0000000..09690e1 --- /dev/null +++ b/releases/v4.9.0.md @@ -0,0 +1,11 @@ +# Release v4.9.0 +Date: 2016-12-22 + +## Description +This release includes: +- Added new default subparser join. +- Important bug fix/improvement: access to parent loop. +- PHP 7 Compatibility check. + +## Commits +- No commits found. diff --git a/releases/v5.1.0.md b/releases/v5.1.0.md new file mode 100644 index 0000000..a1d2b3f --- /dev/null +++ b/releases/v5.1.0.md @@ -0,0 +1,37 @@ +# Release v5.1.0 +Date: 2019-07-22 + +## Description +This release includes: +- Some bug fixes. +- New variable for inline data of preprocessed templates: div.standalone, by default is FALSE. This means that the "foo" variable will not be passed to the template pre-processor. That is, the variables in the parent template will be ignored and only the data specified in the line will be used. +- Do not include anything within the conditional blocks if the conditions have not been resolved. This check prevent infinite loops. +- Priority change for items over filesystem when include o preprocess templates. To force load data from external file, please type the path or full path (ex: block.json) var1: "value1" var2: "value2" } =}. +- Improved the translator. Now you can translate from and to other dialects. +- Fixed dynamic include's paths inside loops. +- Fixed and improve getAuxiliaryEngine. +- Fixed a bug with getAuxiliaryEngine (clone vs assignment). +- Added some new system vars. +- Div.class_name: the name of current invoked class ('div' or child of 'div'). +- Div.super_class_name: the name of super parent of current invoked class name (normally is 'div'). +- Code review. +- Changed scope of ->loadTemplateProperties() to public. +- Other minor fixes. +- Automatic update of template source code after prepareDialect() ... +- ... && new param for ->prepareDialect() for disable automatic update. +- Re-thinking the change in **June 10, 2013** about invalid JSON in assignments. Is important the dynamic path of JSON files. +- Important improvement for loading JSON data from relative path in template variable's assignment. +- Bug fix on constructor, when div var is an object and not an array. +- Added file_exists as allowed function. +- Added in_array as allowed function. +- Optimize the code: change "is_null" as "=== null", because is_null is 250ns slower (in favor of PHP 5). +- Bug fix: better resolution of tags with empty suffix. In this example "list.filter" is a substring of "list.filter.category", and then exists resulting unexpected code if $list.filter is false. +- Important change!: Now NULLs vars exists and are replaced with empty strings. +- Important change!: Fix scope of pre-processed templates inside loops. +- Divengine namespace. +- Bug fix: Fix scope of standalone pre-processed templates. This fix prevents infinite loops and is useful for recursive pre-process in a component based design. +- Bug fix in div::scanMatch. +- Improved: Better resolution of default template for child classes of div, using Reflection. + +## Commits +- No commits found. diff --git a/releases/v5.1.1.md b/releases/v5.1.1.md new file mode 100644 index 0000000..2c8728d --- /dev/null +++ b/releases/v5.1.1.md @@ -0,0 +1,9 @@ +# Release v5.1.1 +Date: 2019-07-22 + +## Description +This release includes: +- Improved support namespaces of div's child. + +## Commits +- No commits found. diff --git a/releases/v5.1.2.md b/releases/v5.1.2.md new file mode 100644 index 0000000..05613ee --- /dev/null +++ b/releases/v5.1.2.md @@ -0,0 +1,11 @@ +# Release v5.1.2 +Date: 2019-08-21 + +## Description +This release includes: +- Fixed orphan conditional parts. +- Fixed standalone preprocessed templates. +- Now this example works. + +## Commits +- No commits found. diff --git a/releases/v5.1.3.md b/releases/v5.1.3.md new file mode 100644 index 0000000..ce0b239 --- /dev/null +++ b/releases/v5.1.3.md @@ -0,0 +1,10 @@ +# Release v5.1.3 +Date: 2019-08-22 + +## Description +This release includes: +- Fixed resolution of templates path for win and *nix OS. +- Fixed the relative path of included templates inside loop. + +## Commits +- No commits found. diff --git a/releases/v5.1.4.md b/releases/v5.1.4.md new file mode 100644 index 0000000..c9af59b --- /dev/null +++ b/releases/v5.1.4.md @@ -0,0 +1,9 @@ +# Release v5.1.4 +Date: 2019-08-23 + +## Description +This release includes: +- New method div::getVersion(). + +## Commits +- No commits found. diff --git a/releases/v5.1.5.md b/releases/v5.1.5.md new file mode 100644 index 0000000..3d9a53e --- /dev/null +++ b/releases/v5.1.5.md @@ -0,0 +1,9 @@ +# Release v5.1.5 +Date: 2019-09-21 + +## Description +This release includes: +- Fixed div::varExists() method. + +## Commits +- No commits found. diff --git a/releases/v5.1.6.md b/releases/v5.1.6.md new file mode 100644 index 0000000..00cde86 --- /dev/null +++ b/releases/v5.1.6.md @@ -0,0 +1,9 @@ +# Release v5.1.6 +Date: 2020-02-11 + +## Description +This release includes: +- Minor fix: Array and string offset access syntax with curly braces is deprecated. + +## Commits +- No commits found. diff --git a/releases/v6.0.0.md b/releases/v6.0.0.md new file mode 100644 index 0000000..24bfcbf --- /dev/null +++ b/releases/v6.0.0.md @@ -0,0 +1,8 @@ +# Release v6.0.0 +Date: 2023-12-24 + +## Description +This release moves the project forward to PHP 8.x and introduces PHPStan checks at level 3. + +## Commits +- No commits found. diff --git a/releases/v6.0.1.md b/releases/v6.0.1.md new file mode 100644 index 0000000..3863459 --- /dev/null +++ b/releases/v6.0.1.md @@ -0,0 +1,8 @@ +# Release v6.0.1 +Date: 2024-01-26 + +## Description +This release improves `div::cop` with Reflection and strict mode, and adds unit tests. + +## Commits +- No commits found. diff --git a/releases/v6.1.0.md b/releases/v6.1.0.md new file mode 100644 index 0000000..dad3289 --- /dev/null +++ b/releases/v6.1.0.md @@ -0,0 +1,8 @@ +# Release v6.1.0 +Date: 2024-08-06 + +## Description +This release integrates `divengine\\functions`, adds short-circuit constant definitions, passes PHPStan level 3, includes more unit tests, and delivers minor refactorings. + +## Commits +- No commits found. diff --git a/releases/v6.1.1.md b/releases/v6.1.1.md new file mode 100644 index 0000000..147530a --- /dev/null +++ b/releases/v6.1.1.md @@ -0,0 +1,8 @@ +# Release v6.1.1 +Date: 2024-08-06 + +## Description +This release is a hotfix for the package version. + +## Commits +- No commits found. diff --git a/releases/v6.1.3.md b/releases/v6.1.3.md index 35c2219..70c041c 100644 --- a/releases/v6.1.3.md +++ b/releases/v6.1.3.md @@ -2,8 +2,11 @@ Date: 2026-02-07 ## Description -TODO: Add release description. +This release focuses on documentation clarity and release tooling. It refines the engine overview and parsing behavior guidance, improves release note generation logic, and aligns workflow configuration with the current versioning and release process. ## Commits +- [Update documentation: enhance the overview and clarify engine behavior and core operations](https://github.com/divengine/div/commit/6e92000055dc530d3f0b05622f5b7dc6ee2bf1be) +- [Update documentation: add notes on parsing behavior, loop control, and engine setup variables](https://github.com/divengine/div/commit/756a5c835a86eb5dd1a57400cd108359a4aaa7c3) +- [Update release notes generation to exclude merge and changelog update commits](https://github.com/divengine/div/commit/bddbb0fb97e7d39b16aca5d0c4e6bfcae9711d6b) - [Add functions for version parsing and release note management; update base tag logic in release notes generation](https://github.com/divengine/div/commit/57b1d49023cbdc38e6dc787af3197e2cf446d9ac) - [Update workflow triggers and version number in configuration files](https://github.com/divengine/div/commit/4cea894ca7aac671b17c3edda176b22ff62b78af) From 9a13a06d41375061a013102e5d3e5e3ff66a9eae Mon Sep 17 00:00:00 2001 From: rafageist Date: Sat, 7 Feb 2026 22:00:02 -0300 Subject: [PATCH 7/9] chore(release): update release notes --- releases/CHANGELOG.md | 460 +++++++++++++++++++++--------------------- releases/v1.1.0.md | 6 +- releases/v1.2.0.md | 15 +- releases/v1.3.0.md | 9 +- releases/v1.4.0.md | 16 +- releases/v1.5.0.md | 8 +- releases/v1.6.0.md | 9 +- releases/v1.7.0.md | 17 +- releases/v1.8.0.md | 31 ++- releases/v1.9.0.md | 122 ++++++++++- releases/v2.0.0.md | 41 +++- releases/v2.1.0.md | 153 +++++++++++++- releases/v2.2.0.md | 268 +++++++++++++++++++++++- releases/v2.3.0.md | 83 +++++++- releases/v2.4.0.md | 28 ++- releases/v2.5.0.md | 25 ++- releases/v2.6.0.md | 62 +++++- releases/v2.7.0.md | 26 ++- releases/v2.8.0.md | 55 ++++- releases/v2.9.0.md | 100 ++++++++- releases/v3.0.0.md | 45 ++++- releases/v3.1.0.md | 27 ++- releases/v3.2.0.md | 37 +++- releases/v3.3.0.md | 7 +- releases/v3.4.0.md | 34 +++- releases/v3.5.0.md | 78 ++++++- releases/v3.6.0.md | 94 ++++++++- releases/v3.7.0.md | 283 +++++++++++++++++++++++++- releases/v3.8.0.md | 8 +- releases/v3.9.0.md | 375 +++++++++++++++++++++++++++++++--- releases/v4.0.0.md | 136 ++++++++++++- releases/v4.1.0.md | 18 +- releases/v4.2.0.md | 93 ++++++++- releases/v4.3.0.md | 170 +++++++++++++++- releases/v4.4.0.md | 21 +- releases/v4.5.0.md | 311 ++++++++++++++++++++++++---- releases/v4.6.0.md | 5 +- releases/v4.7.0.md | 36 +++- releases/v4.8.0.md | 52 ++++- releases/v4.9.0.md | 42 +++- releases/v5.1.0.md | 313 +++++++++++++++++++++++++--- releases/v5.1.1.md | 4 +- releases/v5.1.2.md | 84 +++++++- releases/v5.1.3.md | 7 +- releases/v5.1.4.md | 5 +- releases/v5.1.5.md | 5 +- releases/v5.1.6.md | 5 +- releases/v6.0.0.md | 2 +- releases/v6.0.1.md | 3 +- releases/v6.1.3.md | 1 + 50 files changed, 3314 insertions(+), 521 deletions(-) diff --git a/releases/CHANGELOG.md b/releases/CHANGELOG.md index 988b8a3..33ca774 100644 --- a/releases/CHANGELOG.md +++ b/releases/CHANGELOG.md @@ -423,7 +423,7 @@ November 16, 2016 ``` - TODO: test & release ----------------------------- + November 14, 2016 - add new default subparser join @@ -495,11 +495,11 @@ index.tpl TODO: improve dialect creator tool TODO: check dialect translator method div::translateFrom() ----------------------------- + December 19, 2015 - several tests - Release 4.7 version ----------------------------- + December 12, 2015 - [starting release 4.7] - some bug fixes, thanks to `gracix` and `Takefumi Ota` @@ -638,26 +638,26 @@ September 16, 2014 - big fix: Set the priority to inline data in pre-processed templates above global design vars --- September 11, 2014 ----------------------------- + - bigfix: Save sections of loops and capsules when makeItAgain(); (Div doesn't know the future) ----------------------------- + September 9, 2014 ----------------------------- + - bugfix: Adding items to array in templates {= somearray[]: "new item" =} - bugfix: Don't set item var as design var in div::parseData(); ----------------------------- + September 8, 2014 ----------------------------- + - bugfix: Parse pre-processed templates with all items/vars (Div doesn't know the future) ----------------------------- + August 28, 2014 ----------------------------- + - New feature for preprocessed templates: specific data Syntax: @@ -702,32 +702,32 @@ August 28, 2014 ----------------------------- + August 17, 2014 ----------------------------- + - Security fix: prevent obtrusive code in method calls. Now next code dont work: {= content: ->getPage(file_put_contents('some.txt','some text')) =} ----------------------------- + August 5, 2014 ----------------------------- + - Fix the memory in the loops ----------------------------- + August 4, 2014 ----------------------------- + - Fix macros parsing when a previous template var never match ----------------------------- + August 2, 2014 ----------------------------- + - Allow is_array PHP function in macros - New method for add literal vars in PHP: div::addLiteral(); ----------------------------- + June 30, 2014 ----------------------------- + - Some bugfixs - Add new important security feature: setup literals items/vars, for prevent injections! @@ -757,42 +757,42 @@ output [:1,100;] text to repeat [/] some some some ----------------------------- + February 05, 2014 ----------------------------- + - Memory fixed! ----------------------------- + December 25, 2013 ----------------------------- + - bugfix: div::fileExists and wrong include paths calculation ----------------------------- + December 5, 2013 ----------------------------- + - Improvement of global design vars in loops and capsules ----------------------------- + December 4, 2013 ----------------------------- + - bugfix: div::getFileContents() ----------------------------- + August 30, 2013 ----------------------------- + - An important bug was fixed: the memory in the loops: In div 4.4 dont't work: index.php - -------------------------------- + ---- array("Havana", "Tokyo"))); index.tpl - -------------------------------- + ---- {= foo: [ { title: "Cities", content: '{% cities.tpl %}' @@ -802,7 +802,7 @@ August 30, 2013 {% layout.tpl %} layout.tpl - --------------------------------- + ----- ?$foo [$foo]

    {$title}

    @@ -811,7 +811,7 @@ August 30, 2013 $foo? cities.tpl - --------------------------------- + ----- ?$cities [$cities] {$value} @@ -821,47 +821,47 @@ August 30, 2013 $cities? Output (wrong!) - --------------------------------- + -----

    Cities

    No cities
    Output (great in 4.5) - --------------------------------- + -----

    Cities

    Havana Tokio
    ----------------------------- + July 29, 2013 ----------------------------- + - Decrease of priority in parser's specialchars ----------------------------- + July 27, 2013 ----------------------------- + - bugfixs! - Release 4.4 version ----------------------------- + July 19, 2013 ----------------------------- + - bugfix the translator - New feature: Multi template sources (based on include_path PHP setting) ----------------------------- + June 15, 2013 ----------------------------- + - Improvement of the modifier "escape single quotes" (\') to "escape single/double quotes" (\"). - Improvement of default documentation's template. ----------------------------- + June 15, 2013 ----------------------------- + - Improvement of logs's system - Release 4.3 version ----------------------------- + June 13, 2013 ----------------------------- + - Integration with Google Chrome/Console and Mozilla Firefox/Firebug plugins. Now the engine's messages will be appear in this browsers's features. @@ -897,9 +897,9 @@ June 13, 2013 Solved! ----------------------------- + June 12, 2013 ----------------------------- + - Improvement of relative include/preprocessed templates. Now the next example works: @@ -976,9 +976,9 @@ June 12, 2013 YES true ----------------------------- + June 10, 2013 ----------------------------- + - Improvement of the parser of template's vars: If the value is not valid JSON, it will be considered as a template and will be parsed before decoding. @@ -1017,22 +1017,22 @@ June 10, 2013 --------- New York ----------------------------- + June 08, 2013 ----------------------------- + - Improvement of template's documentation - Release new version 1.1 of Div Dialect Creator - Release the version 4.2 ----------------------------- + June 02, 2013 ----------------------------- + - Fix/improve the translator - Fix/improve the parser ----------------------------- + June 01, 2013 ----------------------------- + - Improvement of the parser of ignored parts - Improvement of the parser of includes - New feature: template's documentation. Now in the comments you can @@ -1078,9 +1078,9 @@ document the template. The documentation's parts have @ as prefix. For example: - Fix the algorithm of getRanges(). - Fix the parser of macros. - Added a new sub-parser's event: afterReplace. ----------------------------- + May 31, 2013 ----------------------------- + - Improvement of the algorithm of getRanges() to make all the possible one. Now Div continues searching ranges after unclosed tags. @@ -1105,34 +1105,34 @@ Div continues searching ranges after unclosed tags. {/ 2013-05-31 ----------------------------- + May 30, 2013 ----------------------------- + - Test new version - Minor bugs was fixed - Improvement of the detection of date formats - Release 4.1 version ----------------------------- + May 29, 2013 ----------------------------- + - Fix and improve the algorithm of div::getVarValue() method. - Fix the detection of conditional parts. ----------------------------- + May 27, 2013 ----------------------------- + - Change to private some div's properties - Release 4.0 version ----------------------------- + May 25, 2013 ----------------------------- + - Improvement of the conditional parts detection ----------------------------- + May 24, 2013 ----------------------------- + - Fixed some bugs in locations and conditional parts. - Created a translator of dialects. Now div have 2 new public methods: @@ -1152,7 +1152,7 @@ in the template's code, for example, the dialect of the current template: Example: index.tpl - ------------------------------ + -- @_DIALECT = smarty.dialect {* this is a comment *} @@ -1165,13 +1165,13 @@ in the template's code, for example, the dialect of the current template: {% other %} other.tpl - ------------------------------ + -- @_DIALECT = twig.dialect {{ foo.bar }} smarty.dialect - ------------------------------ + -- { 'DIV_TAG_IGNORE_BEGIN': '{literal}', 'DIV_TAG_IGNORE_END': '{/literal}', @@ -1180,14 +1180,14 @@ in the template's code, for example, the dialect of the current template: } twig.dialect - ------------------------------- + --- { 'DIV_TAG_REPLACEMENT_SUFFIX': ' }}', 'DIV_TAG_MODIFIER_SIMPLE': '{ ' } index.php - ------------------------------- + --- show('template.tpl'); ?> ----------------------------- + March 18, 2013 ----------------------------- + - Added new variable's modifiers: {&&var} - rawurlencode @@ -1906,9 +1906,9 @@ March 18, 2013 - Improvement of the setItem method ----------------------------- + March 16, 2013 ----------------------------- + - Improved the access to object's public methods @@ -1954,9 +1954,9 @@ March 16, 2013 - Release the 3.6 version ----------------------------- + March 13, 2013 ----------------------------- + - Improved the feature "template vars". Now you can execute the "methods of information". Example: @@ -1996,21 +1996,21 @@ March 13, 2013 The names are: Jones Pete Mark ----------------------------- + March 13, 2013 ----------------------------- + - Improved the detection of orphan conditional parts ----------------------------- + March 8, 2013 ----------------------------- + - Update the documentation - Fixes some bugs of new features - Release the 3.5 version ----------------------------- + February 24, 2013 ----------------------------- + - New feature: locations! Now you can define a diferent locations in your template @@ -2065,9 +2065,9 @@ February 24, 2013 --------------------- Hello ----------------------------- + February 24, 2013 ----------------------------- + - New feature: @empty@ tag for list's blocks [$users] @@ -2076,16 +2076,16 @@ February 24, 2013 Show this if list users is empty [/$users] ----------------------------- + February 19, 2013 ----------------------------- + - The documentation was updated - Improved detection of infinite loops on includes and replacements - Release the 3.4 version ----------------------------- + February 17, 2013 ----------------------------- + - Add new feature: Multiple variable's modifiers Syntax: @@ -2108,15 +2108,15 @@ February 17, 2013 Abc Ab ----------------------------- + February 15, 2013 ----------------------------- + - Fix a critical bug: prevented infinite cycle - Release the 3.3 version ----------------------------- + February 4, 2013 ----------------------------- + - Fix a bug with {ignore} functionality - Add new vars for the iterations: $_previous and $_next. @@ -2145,20 +2145,20 @@ February 4, 2013 - Algorithm improved: 95% more faster. - Release the 3.2 version ----------------------------- + Dec 26, 2012 ----------------------------- + - Improved date's values detection ----------------------------- + Nov 21, 2012 ----------------------------- + - Update documentation - Release 3.1 version ----------------------------- + Nov 21, 2012 ----------------------------- + - Detection of recursive inclusion as an error. For example: index.tpl @@ -2166,26 +2166,26 @@ Nov 21, 2012 {% index %} ----------------------------- + Nov 19, 2012 ----------------------------- + - Improved the algorithm of lists/loops/cycles ----------------------------- + Nov 16, 2012 ----------------------------- + - Allowed "intval" PHP function in formulas ----------------------------- + Nov 4, 2012 ----------------------------- + - Fix some problems - Improvement of some mechanisms - Release the 3.0 version ----------------------------- + Sep 7, 2012 ----------------------------- + - Fix important issue for matchs. Now work the follow example: {= list: [ @@ -2215,18 +2215,18 @@ Sep 7, 2012 {$list.0.shipments.0.adresses.0}
    {$list.0.shipments.0.adresses.0.0}
    ----------------------------- + Sep 2, 2012 ----------------------------- + - Fix bugs of conditions into loops ----------------------------- + Sep 2, 2012 ----------------------------- + - Fix bugs - Release the 2.9 version ----------------------------- + Aug 30, 2012 ----------------------------- + - Improvements to the template's vars. Now you can do this: article.tpl @@ -2248,9 +2248,9 @@ Aug 30, 2012 Footer ----------------------------- + Aug 20, 2012 ----------------------------- + - Delete the DIV_CLASS_NAME constant: now is more simple to change the name of div class. Simply change the name of div class, no more! @@ -2282,9 +2282,9 @@ Aug 20, 2012 {% parent %} ----------------------------- + Aug 18, 2012 ----------------------------- + - The algorithm of text summary was improved. - New feature: IDE's friendly marks @@ -2314,29 +2314,29 @@ Aug 18, 2012 [/$products] ----------------------------- + Aug 17, 2012 ----------------------------- + - Change the type of method of getSystemData from public to static ----------------------------- + Aug 16, 2012 ----------------------------- + - Change the type of method of mixedBool from public to static. - Release the 2.8 version ----------------------------- + Aug 09, 2012 ----------------------------- + - Added new feature: Relative paths for include and preprocessed templates. ----------------------------- + Aug 07, 2012 ----------------------------- + - Freed of the function json_encode of PHP and corrected some errors of this function. ----------------------------- + Aug 05, 2012 ----------------------------- + - Fixed bugs: - If you don't define a variable, the expression is FALSE: @@ -2375,15 +2375,15 @@ Aug 05, 2012 (# 2 + {$var2} #) ----------------------------- + Aug 03, 2012 ----------------------------- + - Fixed bugs - Release the 2.7 version ----------------------------- + Jul 30, 2012 ----------------------------- + - Fixed bugs - Add new feature for json encode. @@ -2399,15 +2399,15 @@ Jul 30, 2012 [1,2,3,4,5] ----------------------------- + Jul 26, 2012 ----------------------------- + - Fixed bugs - Release the 2.6 version ----------------------------- + Jul 08, 2012 ----------------------------- + - Added new features for replacements: multiple replacements @@ -2450,18 +2450,18 @@ Jul 08, 2012 ?> - Fixed bugs ----------------------------- + Jul 02, 2012 ----------------------------- + - Add new features for performance: enable and disable system var div::enableSystemVar("div.session"); div::disableSystemVar("div.server"); ... ----------------------------- + Jun 30, 2012 ----------------------------- + - Fixed bugs - Added new funcionality for log: Save the steps of the parser into log file @@ -2470,9 +2470,9 @@ Jun 30, 2012 ... - Release the 2.5 version ----------------------------- + Jun 13, 2012 ----------------------------- + - Fixed bugs - Added new functionality: html to text @@ -2481,9 +2481,9 @@ Jun 13, 2012 The width integer parameter, wrap the text with this width. ----------------------------- + Jun 8, 2012 ----------------------------- + - Fixed bugs - Added new functionality: text wrap @@ -2496,9 +2496,9 @@ Jun 8, 2012 {br:body:/200} - Release the 2.4 version ----------------------------- + May 27, 2012 ----------------------------- + - Added new functionality: show the teaser of a text. Similar to get a substring of text: {$mytext:100} @@ -2507,9 +2507,9 @@ May 27, 2012 {$mytext:~100} ----------------------------- + May 22, 2012 ----------------------------- + - NEW: Allow to asign a program var to a template var. For example: index.php @@ -2543,9 +2543,9 @@ May 22, 2012 - Release the 2.3 version ----------------------------- + May 19, 2012 ----------------------------- + - NEW: Allowed functions. Now the programmer can enable functions of or written in PHP so that the designer can use them in the templates. @@ -2568,7 +2568,7 @@ May 19, 2012 - NEW: Add new item to list or set a property of object: TEMPLATE - ----------------------------------------- + ------------- ... some more code here ... {= list: [1,2,3] =} @@ -2588,15 +2588,15 @@ May 19, 2012 {$customer.address} ----------------------------- + May 14, 2012 ----------------------------- + - Fixed bugs - Release 2.2 version ----------------------------- + May 13, 2012 ----------------------------- + - New functionality: assign to design vars the result of method! If the programmer implemented a class that inherits of div, then the designer can use the methods of this class. @@ -2637,9 +2637,9 @@ May 13, 2012 Output --------------------------- 50 A B C ----------------------------- + May 12, 2012 ----------------------------- + - Now the definition of data in templates is similar to set a global var in the programmer side and you can re-refine this data every time in the template and now the sequence of the operations @@ -2647,9 +2647,9 @@ May 12, 2012 For example: - ------------------------------ + -- TEMPALTE - ------------------------------ + -- @@ -2673,9 +2673,9 @@ May 12, 2012 Total price: {#invoice_price:2.#} - ------------------------------ + -- OUTPUT - ------------------------------ + -- Invoice price: 90.00 Tax: 20.00 Total price: 110.00 @@ -2781,15 +2781,15 @@ May 12, 2012 1 {$x} 2 {$x} 3 {$x} 4 {$x} 5 {$x} 6 {$x} 7 {$x} 8 {$x} 9 {$x} 10 {$x} ----------------------------- + May 09, 2012 ----------------------------- + - Added aggregate functions for the lists: sum, avg, min, max, and the default count function Now the designer can calculate another statistics from lists, for example: index.php - ------------------------------------ + -------- - ------------------------------------ + -------- index.tpl - ------------------------------------ + -------- Minimum price: {$min:products-price} Maximum price: {$max:products-price} Average of prices: {$avg:products-price} @@ -2821,7 +2821,7 @@ May 09, 2012 Maximum value: {$max:values} Average of values: {$avg:values} Sum of values: {$sum:values} - ------------------------------------ + -------- - Added a new constant constant DIV_CLASS_NAME for define the name of de superclass of div. Now the programmer can change the name of the div class to avoid possible @@ -2851,9 +2851,9 @@ May 09, 2012 {@["kept", false, "NO"]@} ... ----------------------------- + May 08, 2012 ----------------------------- + - Added a new functionality: pre-processed parts. Now you can pre-processed by div any part in template. The pre-processing @@ -2866,9 +2866,9 @@ May 08, 2012 - Release the 2.1 version ----------------------------- + May 06, 2012 ----------------------------- + - Enable two new properties for PHP developers: $__src and $__packages. See the follow example: @@ -2996,14 +2996,14 @@ May 06, 2012 ?> ----------------------------- + April 21, 2012 ----------------------------- + - Change mixedBool() and parseMatch() methods for trim the string values. ----------------------------- + April 14, 2012 ----------------------------- + - Added a new variable for the cycles: $_order, that is $_index + 1. The index begins with 0. The order bigins with 1. This is util when you @@ -3012,14 +3012,14 @@ April 14, 2012 For example: The ordered list: - ------------------------------- + --- [$list] {% reused %} [/$list] The reused template reused.tpl: - ------------------------------- + --- ?$_order {$_order}. $_order? Name: {$name} Address: {$address} @@ -3039,9 +3039,9 @@ April 14, 2012 - Release the 2.0 Version ----------------------------- + April 09, 2012 ----------------------------- + - Fix some grave bugs of iterations functionality and other improvements. @@ -3153,9 +3153,9 @@ April 09, 2012 - Release the 1.9 version ----------------------------- + April 07, 2012 ----------------------------- + - Recovering a lost functionality. In version 1.5 to make the algorithms more efficient we made a mistake and break functionality of the clean the orphan parts. Now in version 1.8 is working again just as quickly. @@ -3183,7 +3183,7 @@ Note: The new added features made a little slower the engine. We are working in the improvement of the algorithms. April 05, 2012 ----------------------------- + - Recovering a lost functionality. In version 1.5 to improve the algorithms made a mistake and break functionality of the Formulas. Now in version 1.7 is working again just as quickly. @@ -3198,7 +3198,7 @@ echo new div("index.tpl", array("name" => "Salvi", "age" => 25), array("name")); - Release the 1.7 version April 2, 2012 ----------------------------- + - In version 1.5 to improve the algorithms made a mistake and lost functionality of the iterations of Lists, which is the priority of an item variable under way, with the same name of a variable outside the loop. Now in version 1.6 is working @@ -3207,7 +3207,7 @@ April 2, 2012 - Release the 1.6 version March 30, 2012 ----------------------------- + - The algorithm was improved. Div is faster now. - Fixed bugs. - A new variable's modifier was added to encode URL. For example: @@ -3217,7 +3217,7 @@ March 30, 2012 - Release the 1.5 version March 28, 2012 ----------------------------- + - Fixed bugs of blocks of conditions - Add new feature named ITERATIONS. @@ -3232,14 +3232,14 @@ March 28, 2012 - Release the 1.4 version March 23, 2012 ----------------------------- + - Prevent the errors of formulas - Prevent the errors of conditions - Fix important bug of @else@ mark of conditions into other conditions and conditionals - Release the 1.3 version March 22, 2012 ----------------------------- + - The @break@ mark Add break mark for breaking the loops. The position of break mark in the block are relevant! @@ -3254,7 +3254,7 @@ March 22, 2012 - Release the 1.2 version March 15, 2012 ----------------------------- + - Fixing some several issues of conditional parts! - Release the 1.1 version \ No newline at end of file diff --git a/releases/v1.1.0.md b/releases/v1.1.0.md index 1d165f4..be0c057 100644 --- a/releases/v1.1.0.md +++ b/releases/v1.1.0.md @@ -2,8 +2,10 @@ Date: 2012-03-15 ## Description -This release includes: -- Fixed several issues of conditional parts. + +- Fixing some several issues of conditional parts! + +- Release the 1.1 version ## Commits - No commits found. diff --git a/releases/v1.2.0.md b/releases/v1.2.0.md index 2a30a48..b315f3a 100644 --- a/releases/v1.2.0.md +++ b/releases/v1.2.0.md @@ -2,8 +2,19 @@ Date: 2012-03-22 ## Description -This release includes: -- The @break@ mark Add break mark for breaking the loops. The position of break mark in the block are relevant. + +- The @break@ mark + Add break mark for breaking the loops. The position of + break mark in the block are relevant! + + Example: + + [$products] + {?( {$_index} == 3 )?}
    @break@ {/?} + {$value}
    + [/$products] + +- Release the 1.2 version ## Commits - No commits found. diff --git a/releases/v1.3.0.md b/releases/v1.3.0.md index 86ba18a..e95d859 100644 --- a/releases/v1.3.0.md +++ b/releases/v1.3.0.md @@ -2,10 +2,11 @@ Date: 2012-03-23 ## Description -This release includes: -- Prevented the errors of formulas. -- Prevented the errors of conditions. -- Fixed important bug of @else@ mark of conditions into other conditions and conditionals. + +- Prevent the errors of formulas +- Prevent the errors of conditions +- Fix important bug of @else@ mark of conditions into other conditions and conditionals +- Release the 1.3 version ## Commits - No commits found. diff --git a/releases/v1.4.0.md b/releases/v1.4.0.md index 2d96ff0..2c44442 100644 --- a/releases/v1.4.0.md +++ b/releases/v1.4.0.md @@ -2,9 +2,19 @@ Date: 2012-03-28 ## Description -This release includes: -- Fixed bugs of blocks of conditions. -- Added new feature named ITERATIONS. + + +- Fixed bugs of blocks of conditions +- Add new feature named ITERATIONS. + + Example: + + [:1,5:] {$value} [/] + + Output: + + 1 2 3 4 5 +- Release the 1.4 version ## Commits - No commits found. diff --git a/releases/v1.5.0.md b/releases/v1.5.0.md index a887fd6..c6796bd 100644 --- a/releases/v1.5.0.md +++ b/releases/v1.5.0.md @@ -2,10 +2,14 @@ Date: 2012-03-30 ## Description -This release includes: + - The algorithm was improved. Div is faster now. - Fixed bugs. -- A new variable's modifier was added to encode URL. +- A new variable's modifier was added to encode URL. For example: + + {&variable} + +- Release the 1.5 version ## Commits - No commits found. diff --git a/releases/v1.6.0.md b/releases/v1.6.0.md index 539f9e2..3bd4bae 100644 --- a/releases/v1.6.0.md +++ b/releases/v1.6.0.md @@ -2,8 +2,13 @@ Date: 2012-04-02 ## Description -This release includes: -- In version 1.5 to improve the algorithms made a mistake and lost functionality of the iterations of Lists, which is the priority of an item variable under way, with the same name of a variable outside the loop. Now in version 1.6 is working again just as quickly. + +- In version 1.5 to improve the algorithms made a mistake and lost functionality + of the iterations of Lists, which is the priority of an item variable under way, + with the same name of a variable outside the loop. Now in version 1.6 is working + again just as quickly. + +- Release the 1.6 version ## Commits - No commits found. diff --git a/releases/v1.7.0.md b/releases/v1.7.0.md index b15de4f..8d7010a 100644 --- a/releases/v1.7.0.md +++ b/releases/v1.7.0.md @@ -2,10 +2,19 @@ Date: 2012-04-05 ## Description -This release includes: -- Recovering a lost functionality. In version 1.5 to improve the algorithms made a mistake and break functionality of the Formulas. Now in version 1.7 is working again just as quickly. -- Added new functionality for programmers in the constructor of div class with new parameter: IGNORE SOME VARIABLES. Example. -- Prevented a bugs with length two first parameters as filenames, in the div constructor. + +- Recovering a lost functionality. In version 1.5 to improve the algorithms made a + mistake and break functionality of the Formulas. Now in version 1.7 is working again + just as quickly. + +- Added new functionality for programmers in the constructor of div class with + new parameter: IGNORE SOME VARIABLES. Example: + +// ignoring the "name" variable +echo new div("index.tpl", array("name" => "Salvi", "age" => 25), array("name")); + +- Prevent a bugs with length two first parameters as filenames, in the div constructor +- Release the 1.7 version ## Commits - No commits found. diff --git a/releases/v1.8.0.md b/releases/v1.8.0.md index 1c36cee..d88ee47 100644 --- a/releases/v1.8.0.md +++ b/releases/v1.8.0.md @@ -2,11 +2,32 @@ Date: 2012-04-07 ## Description -This release includes: -- Recovering a lost functionality. In version 1.5 to make the algorithms more efficient we made a mistake and break functionality of the clean the orphan parts. Now in version 1.8 is working again just as quickly. -- Fixed some grave bugs. -- If a var contain an object, {$var} will be replace with the count of properties. -- Sub matches: now you can write ($var:0,20} or {$var:20} to replace this mark with substr($var, 0, 20);. + +- Recovering a lost functionality. In version 1.5 to make the algorithms more efficient +we made a mistake and break functionality of the clean the orphan parts. Now in version 1.8 +is working again just as quickly. + +- Fix some grave bugs. + +- Added new funtionalities: + - If a var contain an object, {$var} will be repleace with the count of properties + - Sub matches: now you can write ($var:0,20} or {$var:20} to replace this mark with + substr($var, 0, 20); + + With this new functionality you can chop a text in half thank + to the formulas, for example: + + {$text: (# {%text} / 2 #)} + {$text: (# {%text} / 2 #), (# {%text} / 2 #)} + + You can also make use of the variable's modifiers: + + {^text: 1} + +- Release the 1.8 version. + +Note: The new added features made a little slower the engine. We are working +in the improvement of the algorithms. ## Commits - No commits found. diff --git a/releases/v1.9.0.md b/releases/v1.9.0.md index 590bdec..995fef8 100644 --- a/releases/v1.9.0.md +++ b/releases/v1.9.0.md @@ -2,15 +2,119 @@ Date: 2012-04-09 ## Description -This release includes: -- Fixed some grave bugs of iterations functionality and other improvements. -- Custom item variable for lists and mark =>. -- Custom item variable for iterations: you now can specify the iteration variable. -- Nested iterations. The following example... -- New variable for iterations and lists's cycle. -- $_list, that it contains the list's name. -- $_item, that it contains the list's item. -- $_key, that it contains the item's key. + + +- Fix some grave bugs of iterations functionality and other improvements. + +- Added a new functionalitites: + - Custom item variable for lists and mark =>. For example: + + {= clients: [ + { + name: 'John', + products: [{name: 'Banana', price: 1.2},{name: 'Potato', price: 1.3}] + } + ] + =} + + [$clients] client => + [$products] + {$client.name} - {$name}
    + [/$products] + [/$clients] + + + - Custom item variable for iterations: you now can specify the iteration variable. For example: + + [:1,100,i:] + The current value is {$i} + [/] + + - Nested iterations. The following example... + + [:1,10,i:] + [:1,10,j:] + {$i} * {$j} = (# {$i} * {$j} #)
    + [/] + [/] + + ...is similar to: + + "; + + ?> + + - New variable for iterations and lists's cycle + + - $_list, that it contains the list's name. + + For example: + + [$products] + {$_list} + [/$products] + + Div associates a name to each iteration that you define. With this new functionality + you can know the name of the iteration inside the cycle of the iteration. + + Also, if you use the recursion, you can work now with the name of the list thanks to + this new variable that doesn't collapse with a variable inside the cycle. + + For example: + + {= list: "products", + products: [ + count: 3, + list: ["Banana", "Potato" , "Rice"] + ] + =} + + [{$list}] + {$_list} <--{ This shows the same thing that {$list} that is 'products' ... }--> + {$list} <--{ This shows the count of items of [$list] }--> + [$list] <--{ and this list is a list into the parent cycle }--> + {$value}, <--{ This shows Banana, Potato, Rice }--> + [/$list] + [/{$list}] + + - $_item, that it contains the list's item + + For example: + + {= products: [ + { + name: "Banana", + price: 1.2 + }, + { + name: "Potato", + price: 1.3 + } + ] =} + + [$products] + {$_item} + {$_item.price} is similar to {$price} + [/$products] + + - $_key, that it contains the item's key + + For example: + + [$products] + [$_item] + {$_key}: {$value} + [/$_item] + [/$products] + +- Release the 1.9 version + + ## Commits - No commits found. diff --git a/releases/v2.0.0.md b/releases/v2.0.0.md index 058c9f0..da9cdb1 100644 --- a/releases/v2.0.0.md +++ b/releases/v2.0.0.md @@ -2,10 +2,43 @@ Date: 2012-04-14 ## Description -This release includes: -- Added a new variable for the cycles: $_order, that is $_index + 1. The index begins with 0. The order begins with 1. This is useful when you need to build an ordered list without
      tag and reused item template. -- Added new variable's modifiers: html and br. -- Fixed bugs of recursion and recovered the high priority of variables into the cycles. + + +- Added a new variable for the cycles: $_order, that is $_index + 1. + The index begins with 0. The order bigins with 1. This is util when you + need build a ordered list without
        tag and reused item template. + + For example: + + The ordered list: + --- + + [$list] + {% reused %} + [/$list] + + The reused template reused.tpl: + --- + + ?$_order {$_order}. $_order? Name: {$name} Address: {$address} + + On the other hand if you use the following template for reuse.tpl, + the first order number will be hidden and the template is more complicated: + + ?$_index (# {$_index} + #). $_index? Name: {$name} Address: {$address} + +- Added new variable's modifiers: html and br + + {html:variable} convert all applicable chracters to HTML entities (see the + documentation of htmlentities() PHP function) + + {br:variable} convert all \n to
        + +- Fixed bugs of recursivity and recovered the high priority of variables into the cycles. + +- Release the 2.0 Version + + ## Commits - No commits found. diff --git a/releases/v2.1.0.md b/releases/v2.1.0.md index 3640cfb..4921fb4 100644 --- a/releases/v2.1.0.md +++ b/releases/v2.1.0.md @@ -2,16 +2,153 @@ Date: 2012-05-08 ## Description -This release includes: -- Changed mixedBool() and parseMatch() methods for trim the string values. -- Enabled two new properties for PHP developers: $__src and $__packages. -- If you want that the names of the files have a prefix, specify it in constant PACKAGES or in the property $__packages of a class that extends the div. See. -- Added new constant DIV_DEFAULT_TPL_FILE_EXT for define a template file extension. You can define this constant BEFORE include the div.php script. The default value for this constant is the string "tpl". -- Added new constant DIV_DEFAULT_DATA_FILE_EXT for define a data file extension. You can define this constant BEFORE include the div.php script. The default value for this constant is the string "json". + +- Change mixedBool() and parseMatch() methods for trim the string values. + + + + +- Enable two new properties for PHP developers: $__src and $__packages. + See the follow example: + + + +- If you want that the names of the files have a prefix, specify it in constant + PACKAGES or in the property $__packages of a class that extends the div. See + the following examples: + + Example 1 + ---------------- + + + Example 2 + ---------------- + + +- Add new constant DIV_DEFAULT_TPL_FILE_EXT for define a template file extension. + You can define this constant BEFORE include the div.php script. The default value + for this constant is the string "tpl". For example: + + + +- Add new constant DIV_DEFAULT_DATA_FILE_EXT for define a data file extension. + You can define this constant BEFORE include the div.php script. The default value + for this constant is the string "json". For example: + + + - Implement the show() method. -- If you don't pass the value of $src for the div class constructor, then Div assumes that $src is the name of the class :). -- Enabled the div extends for OOP in the programmer side. The name of the properties should not begin with __ (double underscore). See the follow example. + + show(); + + ?> + +- If you don't pass the value of $src for the div class constructor, then + Div assumes that $src is the name of the class :) + + + +- Enable the div extends for OOP in the programmer side. The name of the properties + should not begin with __ (double underscore). See the follow example: + + Page.tpl + ------------- +

        {$title}{$body}

        + + Page.php + ------------- + + + index.php + ------------- + title = "Hello world"; + $page->body = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.."; + $page->show(); // or echo $page; + + ?> + + + - Added a new functionality: pre-processed parts. + Now you can pre-processed by div any part in template. The pre-processing + are similar to include, but the pre-processing parse the code before including it. + + Include is: {% part.tpl %} (include and then parse) + Pre-processing is {%% part.tpl %%} (parse and then include) + + IMPORTANT!: The pre-processing have a priority with regard to the list interations. + +- Release the 2.1 version + + + ## Commits - No commits found. diff --git a/releases/v2.2.0.md b/releases/v2.2.0.md index df34065..5673bc5 100644 --- a/releases/v2.2.0.md +++ b/releases/v2.2.0.md @@ -2,17 +2,265 @@ Date: 2012-05-14 ## Description -This release includes: -- Added aggregate functions for the lists: sum, avg, min, max, and the default count function. -- Added a new constant constant DIV_CLASS_NAME for define the name of de superclass of div. Now the programmer can change the name of the div class to avoid possible collisions the class's names of his application. + +- Added aggregate functions for the lists: sum, avg, min, max, and the default count function + + Now the designer can calculate another statistics from lists, for example: + + index.php + -------- + array( + array("name" => "Banana", "price" => 20.5), + .... + ... + ... + ), + "values" => array(10,20,30,40,50,60) + )); + + ... + ?> + -------- + + index.tpl + -------- + Minimum price: {$min:products-price} + Maximum price: {$max:products-price} + Average of prices: {$avg:products-price} + Sum of prices: {$sum:products-price} + Count of products with price: {$count:products-price} or {$products-price} + + + + Minimum value: {$min:values} + Maximum value: {$max:values} + Average of values: {$avg:values} + Sum of values: {$sum:values} + -------- + +- Added a new constant constant DIV_CLASS_NAME for define the name of de superclass of div. + Now the programmer can change the name of the div class to avoid possible + collisions the class's names of his application. + - Added a new functionality: default replacements by variable. -- Now the definition of data in templates is similar to set a global var in the programmer side and you can re-refine this data every time in the template and now the sequence of the operations is not ignored. The variables have arrived. -- Fixed bugs. -- Added new functionality: capsules!, with the symbol of Div logo!.... of course. -- Added new feature for iterations functionality: now you can specify a STEP for iteration. -- Another way to define the iteration var with high priority. Now the follow templates are similars. -- New functionality: assign to design vars the result of method! If the programmer implemented a class that inherits of div, then the designer can use the methods of this class. -- Fixed bugs. + + Now the programmer and the designer can define the default replacements for values + by variable. For example: + + Set the default replacement in PHP: + + true)); + ?> + + + Or set the default replacement in the template: + + ... + {@["kept", true, "YES"]@} + {@["kept", false, "NO"]@} + ... + + + + +- Now the definition of data in templates is similar to set a global var in the programmer side + and you can re-refine this data every time in the template and now the sequence of the operations + is not ignored. The variables have arrived! + + For example: + + -- + TEMPALTE + -- + + + + {= products: [ + {price: 10, qty: 5}, + {price: 20, qty: 2} + ] =} + + {= invoice_price: 0 =} + {= tax: 20 =} + + [$products] {= invoice_price: (# {$invoice_price} +{$qty} * {$price} #) =} [/$products] + + Invoice price: {#invoice_price:2.#}
        + + Tax: {#tax:2.#}
        + + + + {= invoice_price: (# {$invoice_price} + {$tax} #) =} + + Total price: {#invoice_price:2.#} + + -- + OUTPUT + -- + Invoice price: 90.00 + Tax: 20.00 + Total price: 110.00 + + +- Fixed bugs + +- Add new functionality: capsules!, with the symbol of Div logo!.... of course! + + Now you can create capsules inside the insole to reduce the code and to facilitate + the work with objects and arrangements. A capsule consists on a block that fulfills + the following syntax: + + [[variable + + ... In this section you can use the properties of variable if it is + an object or their keys if it is an array ... + + variable]] + + For example: + + index.php + ------------------- + + array( + "name" => "Banana", + "price" => 20.4 + ) + )); + ... + ?> + + index.tpl + --------------------- + + [[product + Name: {$name}
        + Price: {$price}
        + product]] + + Enjoy! + +- Add new feature for iterations functionality: now you can specify a STEP for iteration. + + Syntax: + ------------------ + + Variant 1: + + [:from,to,var,step:] + + Variant 2: + + [:from,to,step:] + + Example 1: + ---------------- + + Template: + + [:1,10,2:] {$value} [/] + + Output: + + 1 3 5 7 9 + + Example 2: + ----------------- + + [:1,10,i,2:] {$i} [/] + + Output: + + 1 3 5 7 9 + + Example 3: + ----------------- + [:10,1,i,2:] {$i} [/] + + 10 8 6 4 2 + +- Another way to define the iteration var with high priority. Now the follow templates are similars: + + Template 1: + + [:1,10,x:] .... [/] + + Template 2: + + [:1,10:] x => .... [/] + + The follow example shows the priority of this new way: + + Template: + + [:1,10,x:] y => {$y} {$x} [/] + + Output: + + 1 {$x} 2 {$x} 3 {$x} 4 {$x} 5 {$x} 6 {$x} 7 {$x} 8 {$x} 9 {$x} 10 {$x} + + + +- New functionality: assign to design vars the result of method! If the programmer + implemented a class that inherits of div, then the designer can use the methods of this + class. + + Syntax for template: + + {= variable: ->methodName(params as JSON) =} + + For example: + + Page.php + -------------------------- + x + $params->y; + } + + public function getLetters(){ + return array("A","B","C"); + } + + } + ?> + + Page.tpl + --------------------------- + + {= sum: ->getSum(x: 20, y: 30) =} + + {$sum} + + {= lts: ->getLetters() =} + + [$lts] {$value} [/$lts] + + Output + --------------------------- + 50 A B C + + +- Fixed bugs +- Release 2.2 version + + ## Commits - No commits found. diff --git a/releases/v2.3.0.md b/releases/v2.3.0.md index 55530a8..48b2151 100644 --- a/releases/v2.3.0.md +++ b/releases/v2.3.0.md @@ -2,10 +2,85 @@ Date: 2012-05-22 ## Description -This release includes: -- New: Allowed functions. Now the programmer can enable functions of or written in PHP so that the designer can use them in the templates. -- New: Add new item to list or set a property of object. -- New: Allow to asign a program var to a template var. + +- NEW: Allowed functions. Now the programmer can enable functions + of or written in PHP so that the designer can use them in the templates. + + + + index.tpl + ----------------- + (# sum(2,3) #) + +- NEW: Add new item to list or set a property of object: + + TEMPLATE + ------------- + ... some more code here ... + + {= list: [1,2,3] =} + {= customer: { + name: "Peter", + phone: "222-444555" + } =} + + ... some more code here ... + + {= list[]: 4 =} + {= customer[address]: #221 street 45 =} + + ... some more code here ... + + {$list.4} + + {$customer.address} + + + +- NEW: Allow to asign a program var to a template var. For example: + + index.php + ------------- + 5)); + ... + ?> + + index.tpl + ------------- + + {= another: $some =} + + {$another} + + Output + ------------- + 5 + + Also you can asign to the specific property of template var: + + index.tpl + -------------- + {= someobj: { + property: "$some" + } =} + + {$someobj.property} + +- Release the 2.3 version + + ## Commits - No commits found. diff --git a/releases/v2.4.0.md b/releases/v2.4.0.md index 2e06933..0bdc508 100644 --- a/releases/v2.4.0.md +++ b/releases/v2.4.0.md @@ -2,10 +2,30 @@ Date: 2012-06-08 ## Description -This release includes: -- Added new functionality: show the teaser of a text. Similar to get a substring of text. -- Fixed bugs. -- Added new functionality: text wrap. + +- Added new functionality: show the teaser of a text. Similar to get a substring of text: + + {$mytext:100} + + If you add the symbol ~, you can retrieve the teaser of $mytext: + + {$mytext:~100} + + +- Fixed bugs +- Added new functionality: text wrap + + If you needed the wrap of a text with a specific width, you can do this: + + {$body:/200} + + If you use the br modifier, the text wrap take effect on the web: + + {br:body:/200} +- Release the 2.4 version + + ## Commits - No commits found. diff --git a/releases/v2.5.0.md b/releases/v2.5.0.md index e0c1801..d5e263e 100644 --- a/releases/v2.5.0.md +++ b/releases/v2.5.0.md @@ -2,11 +2,26 @@ Date: 2012-06-30 ## Description -This release includes: -- Fixed bugs. -- Added new functionality: html to text. -- Fixed bugs. -- Added new funcionality for log: Save the steps of the parser into log file. + +- Fixed bugs +- Added new functionality: html to text + + {txt} ... some html code here .. {/txt} + {txt} width => ... some html code here {/txt} + + The width integer parameter, wrap the text with this width. + + + +- Fixed bugs +- Added new funcionality for log: Save the steps of the parser into log file + + // Save the steps of the parser into log file + div::logOn("mylogfile.log"); + ... +- Release the 2.5 version + + ## Commits - No commits found. diff --git a/releases/v2.6.0.md b/releases/v2.6.0.md index c23ee21..7a3b4ea 100644 --- a/releases/v2.6.0.md +++ b/releases/v2.6.0.md @@ -2,11 +2,63 @@ Date: 2012-07-26 ## Description -This release includes: -- Added new features for performance: enable and disable system var. -- Added new features for replacements: multiple replacements. -- Fixed bugs. -- Fixed bugs. + +- Add new features for performance: enable and disable system var + + div::enableSystemVar("div.session"); + div::disableSystemVar("div.server"); + ... + + + +- Added new features for replacements: multiple replacements + + + + {= replac: [ + ['search this string', 'replace with this string', false], + ] =] + + + + {:replac} + + ... some code here .... + + {:/replac} + + + Example: + ---------- + + {= php-code: [ + ['echo ', 'echo '], + ['/\'([^\'](?:\\.|[^\\\']*)*)\'/i', '\'$1\'',true] + ] =} + + {:php-code} + + + + {:/php-code} + + Output: + ---------- + + echo 'hello world' + ?> +- Fixed bugs + + + +- Fixed bugs +- Release the 2.6 version + + ## Commits - No commits found. diff --git a/releases/v2.7.0.md b/releases/v2.7.0.md index 53548d2..8945bfb 100644 --- a/releases/v2.7.0.md +++ b/releases/v2.7.0.md @@ -2,10 +2,28 @@ Date: 2012-08-03 ## Description -This release includes: -- Fixed bugs. -- Added new feature for json encode. -- Fixed bugs. + +- Fixed bugs +- Add new feature for json encode. + + Example: + + array(1,2,3,4,5))); + + {json:variable} + + Outoput: + + [1,2,3,4,5] + + + +- Fixed bugs +- Release the 2.7 version + + ## Commits - No commits found. diff --git a/releases/v2.8.0.md b/releases/v2.8.0.md index 355eefc..aec8920 100644 --- a/releases/v2.8.0.md +++ b/releases/v2.8.0.md @@ -2,12 +2,59 @@ Date: 2012-08-16 ## Description -This release includes: -- If you don't define a variable, the expression is FALSE. -- If you don't define a variable, the formula will be ignored. + +- Fixed bugs: + - If you don't define a variable, the expression is FALSE: + + Example: + "some")); // var2 is missing + + index.tpl + ---------- + + {?( "{$var1}" == "some" && "{$var2}" == "another" )?) + Part 1 + @else@ + Part 2 + {/?} + + Output: + ---------- + Part 2 + + - If you don't define a variable, the formula will be ignored: + + Example: + 2)); // var2 is missing + + index.tpl + ---------- + + (# {$var1} + {$var2} #) + + Output: + ---------- + + (# 2 + {$var2} #) + + + - Freed of the function json_encode of PHP and corrected some errors of this function. + + + - Added new feature: Relative paths for include and preprocessed templates. -- Changed the type of method of mixedBool from public to static. + + + +- Change the type of method of mixedBool from public to static. +- Release the 2.8 version + + ## Commits - No commits found. diff --git a/releases/v2.9.0.md b/releases/v2.9.0.md index 842d39e..37d8171 100644 --- a/releases/v2.9.0.md +++ b/releases/v2.9.0.md @@ -2,14 +2,100 @@ Date: 2012-09-02 ## Description -This release includes: -- Changed the type of method of getSystemData from public to static. + +- Change the type of method of getSystemData from public to static + + - The algorithm of text summary was improved. -- New feature: IDE's friendly marks . -- Delete the DIV_CLASS_NAME constant: now is more simple to change the name of div class. Simply change the name of div class, no more. -- Fixed problem of template vars's scope. The inheritance mechanism is more simple now. -- Improvements to the template's vars. Now you can do this. -- Fixed bugs. +- New feature: IDE's friendly marks + + Example: + + + +

        Name: {$name}

        +

        Price: {$price}

        + + + Expensive product + + + + + Is similar to: + + [$products] + +

        Name: {$name}

        +

        Price: {$price}

        + + {?( {$price} > 10 )?} + Expensive product + {/?} + + [/$products] + + + +- Delete the DIV_CLASS_NAME constant: now is more simple to change the name of + div class. Simply change the name of div class, no more! + +- Fix problem of template vars's scope. The inheritance mechanism is more simple now: + + ------------------- + parent.tpl + ------------------- + + {= block1: + + ...some code here... + + =} + + + {$block1} + + ------------------- + child.tpl + ------------------- + + {= *block1: + + ...some another code here... + + =} + + + {% parent %} + + + +- Improvements to the template's vars. Now you can do this: + + article.tpl + ----------------- + +

        {$title}

        +

        {$body}

        + + + page.tpl + ------------------ + {= content: article =} + + Header + + {$content} + + Footer + + + +- Fix bugs +- Release the 2.9 version + ## Commits - No commits found. diff --git a/releases/v3.0.0.md b/releases/v3.0.0.md index ac23fca..ab8e979 100644 --- a/releases/v3.0.0.md +++ b/releases/v3.0.0.md @@ -2,11 +2,46 @@ Date: 2012-11-04 ## Description -This release includes: -- Fixed bugs of conditions into loops. -- Fixed important issue for matchs. Now work the follow example. -- Fixed some problems. -- Improved some mechanisms. + +- Fix bugs of conditions into loops + + +- Fix important issue for matchs. Now work the follow example: + + {= list: [ + { + name: "Banana", + price: 20, + shipments: [ + { + date: "2012-05-09", + packages: [ + [20, 30, 40] + ] + } + ] + }, + { + name: "Potato", + price: 40 + } + ] =} + + {$list}
        + {$list.0}
        + {$list.0.shipments}
        + {$list.0.shipments.0}
        + {$list.0.shipments.0.adresses}
        + {$list.0.shipments.0.adresses.0}
        + {$list.0.shipments.0.adresses.0.0}
        + + + +- Fix some problems +- Improvement of some mechanisms +- Release the 3.0 version + + ## Commits - No commits found. diff --git a/releases/v3.1.0.md b/releases/v3.1.0.md index 32faa9e..2b572e2 100644 --- a/releases/v3.1.0.md +++ b/releases/v3.1.0.md @@ -2,11 +2,28 @@ Date: 2012-11-21 ## Description -This release includes: -- Allowed "intval" PHP function in formulas. -- Improved the algorithm of lists/loops/cycles. -- Detection of recursive inclusion as an error. -- Updated documentation. + +- Allowed "intval" PHP function in formulas + + + +- Improved the algorithm of lists/loops/cycles + + + +- Detection of recursive inclusion as an error. For example: + + index.tpl + ------------- + + {% index %} + + + +- Update documentation +- Release 3.1 version + + ## Commits - No commits found. diff --git a/releases/v3.2.0.md b/releases/v3.2.0.md index 49f3ccb..f13803f 100644 --- a/releases/v3.2.0.md +++ b/releases/v3.2.0.md @@ -2,11 +2,40 @@ Date: 2013-02-04 ## Description -This release includes: -- Improved date's values detection. -- Fixed a bug with {ignore} functionality. -- Added new vars for the iterations: $_previous and $_next. + +- Improved date's values detection + + + +- Fix a bug with {ignore} functionality +- Add new vars for the iterations: $_previous and $_next. + + index.tpl + ------- + {= list: [10,5,7,12,8,8,10,10] =} + [$list] + {= _previous: 0 =} + {= _next: infinite =} + {$_previous}..{$value}..{$_next} + [/$list] + + Output + ------ + 0..1..2 + 1..2..3 + 2..3..4 + 3..4..5 + 4..5..6 + 5..6..7 + 6..7..8 + 7..8..9 + 8..9..10 + 9..10..infinite + - Algorithm improved: 95% more faster. +- Release the 3.2 version + + ## Commits - No commits found. diff --git a/releases/v3.3.0.md b/releases/v3.3.0.md index a115326..f3bd9fe 100644 --- a/releases/v3.3.0.md +++ b/releases/v3.3.0.md @@ -2,8 +2,11 @@ Date: 2013-02-15 ## Description -This release includes: -- Fixed a critical bug: prevented infinite cycle. + +- Fix a critical bug: prevented infinite cycle +- Release the 3.3 version + + ## Commits - No commits found. diff --git a/releases/v3.4.0.md b/releases/v3.4.0.md index 9b4667f..640ffb1 100644 --- a/releases/v3.4.0.md +++ b/releases/v3.4.0.md @@ -2,10 +2,36 @@ Date: 2013-02-19 ## Description -This release includes: -- Added new feature: Multiple variable's modifiers. -- The documentation was updated. -- Improved detection of infinite loops on includes and replacements. + +- Add new feature: Multiple variable's modifiers + + Syntax: + ---------- + {$varname|modifier1|modifier2|modifier3|...|} + + index.tpl + ---------- + {= word: "ABCDEFG" =} + + {$word|0,3|} + {$word|0,3|_|} + {$word|0,3|_|^|} + {$word|0,3|_|^|~2|} + + Output + ------- + ABC + abc + Abc + Ab + + + +- The documentation was updated +- Improved detection of infinite loops on includes and replacements +- Release the 3.4 version + + ## Commits - No commits found. diff --git a/releases/v3.5.0.md b/releases/v3.5.0.md index 1f097f9..9344f27 100644 --- a/releases/v3.5.0.md +++ b/releases/v3.5.0.md @@ -2,12 +2,78 @@ Date: 2013-03-08 ## Description -This release includes: -- New feature: @empty@ tag for list's blocks. -- New feature: locations. -- Improved the conditional parts: the first and last blank space are removed. -- Updated the documentation. -- Fixes some bugs of new features. + +- New feature: @empty@ tag for list's blocks + + [$users] + {$name} + @empty@ + Show this if list users is empty + [/$users] + + + +- New feature: locations! + + Now you can define a diferent locations in your template + and put in this locations any content. + + + Example: + ----------------- + (( top )) + + (( any )) Some content here (( any )) + + (( bottom )) + + {{top + This is the top of the page + top}} + + {{bottom + This is the bottom of the page + bottom}} + + {{any +
        + any}} + + Output: + ----------------- + This is the top of the page + +
        Some content here
        + + This is the bottom of the page + +- Improvement of the conditional parts: the first and last blank space are removed. + + In Div 1.0 to 3.4: + --------------------- + + ?$what Hello $what? + + Output: + --------------------- + Hello + + From Div 3.5: + --------------------- + + ?$what Hello $what? + + Output: + --------------------- + Hello + + + +- Update the documentation +- Fixes some bugs of new features +- Release the 3.5 version + + ## Commits - No commits found. diff --git a/releases/v3.6.0.md b/releases/v3.6.0.md index 08bbc74..faad8d5 100644 --- a/releases/v3.6.0.md +++ b/releases/v3.6.0.md @@ -2,10 +2,98 @@ Date: 2013-03-16 ## Description -This release includes: -- Improved the detection of orphan conditional parts. + +- Improved the detection of orphan conditional parts + + + - Improved the feature "template vars". Now you can execute the "methods of information". -- Improved the access to object's public methods. + + Example: + + index.php + ---------------- + + + index.tpl + ------------------ + + somedata is: {$somedata} + + {= names: ->getNames() =} + + The names are: [$names] {$value} [/$names] + + + Output + -------------------- + somedata is: 100 + + The names are: Jones Pete Mark + + + + +- Improved the access to object's public methods + + index.php + ------------------- + first_name = $first_name; + $this->last_name = $last_name; + } + function getCompleteName(){ + return $this->first_name.' '.$this->last_name; + } + } + + echo new div('index.tpl', array( + 'person' => new Person('John', 'Nash') + )); + + index.tpl + --------------------- + [[person + + {= cn: ->getCompleteName() =} + + First Name: {$first_name} + Last Name: {$last_name} + Complete name: {$cn} + + person]] + + Output + ---------------------- + First Name: John + Last Name: Nash + Complete name: John Nash + +- Release the 3.6 version + + ## Commits - No commits found. diff --git a/releases/v3.7.0.md b/releases/v3.7.0.md index dad67eb..8c54dd8 100644 --- a/releases/v3.7.0.md +++ b/releases/v3.7.0.md @@ -2,18 +2,281 @@ Date: 2013-03-30 ## Description -This release includes: -- Added new feature for programmers: custom variable's modifier. -- Added new feature for programmers: the hooks!. The hooks are. -- Improved the setItem method. -- Added a new feature for programmers: the method changeTemplate(). -- Improved the show() method with a new parameter: specific template. + +- Added new variable's modifiers: + + {&&var} - rawurlencode + {'var} - escape unescaped single quotes + {js:var} - escape quotes and backslashes, newlines, etc. + {$var:[string format]} - format the value with sprintf PHP function + +- Added new feature for programmers: custom variable's modifier + + For add a new custom variable's modifier you need call the method: + + div::addCustomModifier($prefix, $function) + + The parameter $function can be the name of function or the name of static method of a class, for example + + div::addCustomModifier('upper', 'MyModifiers::upper'); + + Example: + ---------------- + index.php + + 'http://localhost')); + + ?> + + index.tpl + ----------- + + {upi:url} + + + Output + ----------- + http%3A//localhost + +- Added new feature for programmers: the hooks!. The hooks are: + + beforeBuild, afterBuild, beforeParse, afterParse + + Example: + + index.php + --------------- + class HomePage extends div{ + + public function beforeBuild(){ + $this->__src = "index"; + $this->setItem(array( + "title" => "Hello World" + )); + } + } + + echo new HomePage(); + + index.tpl + --------------- +

        {$title}

        + + Output + ---------------- +

        Hello World

        + +- Improvement of the setItem method + + + +- Added a new feature for programmers: the method changeTemplate() + + "Hello world")); + + echo $tpl; // $tpl->show(); + + $tpl->changeTemplate('index2.tpl'); + + echo $tpl; // $tpl->show(); + + ?> + +- Improvement of the show() method with a new parameter: specific template + + title = "Hello world"; + $tpl->show('template.tpl'); + + ?> + + - Some functions of PHP are enabled in formulas and conditions. + - Added a new system var named: $div.ascii. This var contain the all chars of ASCII table. -- From version 3.6 Div maintains a policy regarding the use of objects: if an object has implemented the method __ toString then be treated as a character string. We are working to improve the policy and avoid unhappy. -- Improved the speed. -- Improved the options arround the __toString method of objects in 3 scopes. See the example below. -- Improved the interpretation of third parameter of the constructor as a string with the variables's names. + + + + index.tpl + ----------- + {$div.ascii.64} + + is similar to + + (# chr(64) #) + + but the replacement is faster than calculation + + Output: + ------- + @ + + is similar to + + @ + + but the replacement is faster than calculation + + + +- From version 3.6 Div maintains a policy regarding the use of objects: if an +object has implemented the method __ toString then be treated as a character string. +We are working to improve the policy and avoid unhappy. + + index.php + + name = $name; + $this->price = $price; + } + + public function __toString(){ + return $this->name.' ($'.$this->price.')'; + } + } + + echo new div('index.tpl', array("products" => array(new Product('Banana', 10)))); + ?> + + index.tpl + + [$products] + {$value} + [/$products] + + Output + Banana ($10) + + We are working to improve the policy and avoid unhappy. + + +- Improvement of the speed. +- Improvement of the options arround the __toString method of objects in 3 scopes. See the example below. + + The old policy: + + "if an object has implemented the method __toString then be treated as a string" + + It was changed for: + + "if an object has implemented the method __toString, you can work with the object as a character string" + + + Example: + + index.php + --------- + name = $name; + $this->price = $price; + } + + public function __toString(){ + return $this->name.' ($'.$this->price.')'; + } + } + + // The object as string + echo new div('index.tpl', array("product" => new Product('Banana', 10))); + + // Template scope + echo new div('index1.tpl', array(new Product('Banana', 10))); + + // Capsule scope + echo new div('index2.tpl', array("product" => new Product('Banana', 10))); + + // Loop's body scope + echo new div('index3.tpl', array("products" => array(new Product('Banana', 10)))); + + ?> + + index.tpl + ------------ + {$product} + + Output for index.tpl + -------------------- + Banana ($10) + + index1.tpl + ---------- + {$value} + + is similar to + + {$_to_string} + + index2.tpl + ---------- + [[product + + {$value} + + is similar to + + {$_to_string} + + product]] + + index3.tpl + ---------- + [$products] + {$value} + + is similar to + + {$_to_string} + [/$products] + + Same output for index1, index2 and index3 + ------------- + Banana ($10) + + is similar to + + Banana ($10) + + +- Improved the interpretation of third parameter of the constructor + as a string with the variables's names. + + echo new div('index.tpl', array('name' => 'Peter', 'age' => 25, 'sex' => 'M'), 'name,age'); + +- Release the 3.7 version + + ## Commits - No commits found. diff --git a/releases/v3.8.0.md b/releases/v3.8.0.md index b0a8882..48a9080 100644 --- a/releases/v3.8.0.md +++ b/releases/v3.8.0.md @@ -2,8 +2,12 @@ Date: 2013-04-03 ## Description -This release includes: -- Version 3.7 was released with a serious error that was corrected in the 3.8. + +- Version 3.7 was released with a serious error that was corrected in the 3.8 + +- Release the 3.8 version + + ## Commits - No commits found. diff --git a/releases/v3.9.0.md b/releases/v3.9.0.md index 9e59899..5ccaace 100644 --- a/releases/v3.9.0.md +++ b/releases/v3.9.0.md @@ -2,37 +2,360 @@ Date: 2013-05-18 ## Description -This release includes: + - The scalar values as a complex values! What? -- Fixed some issues. -- New method div::isSring as a safe is_string(). -- If is a string return true. -- If is a object with __toString method return true. -- Bug fix of template variables when it use object's methods Now you can call a object's method with some ways. -- Bug fix of loops, prevent a recursion with var '_item' as object inside the same object. -- The order respect of template variables's manipulation was improved. -- The template variables's manipulation was improved. -- The method setItem and getItem was improved with detection of complex variable's names. -- Bug fix in the bodies of multi-replacements. -- Changed the name of method multiReplace by parseMultiReplace. -- Performance: work remembered! Now the engine can remember some actions from previous work and increase their speed. + + Yes! Now all the scalar values can be used as strings. Then, the strings can be + used like complex values, that is to say, as group of characters. For example: + + index.tpl + -------------- + {= name: "Peter" =} + + + {$name.0} + + + {$name.1} + + {= x: 537 =} + + + {$x.0} + + + {$x.1} + + + [$name]{$value} [/$name] + + + [$x] {$value} * [/$x] = (# [$x] {$value} * [/$x] 1 #) + + Output: + ---------------- + P + + e + + 5 + + 3 + + P e t e r + + 5 * 3 * 7 = 105 + + + +- Fix some issues +- New method div::isSring as a safe is_string(): + - if is a string return true + - if is a object with __toString method return true + + + +- bugfix of template variables when it use object's methods + Now you can call a object's method with some ways: + + Similar to PHP: + + {= result: ->method(param1, param2, param3) =} + + One parameter as JSON data: + + {= result: ->method({param1: value1, param2: value2}); + +- bugfix of loops, prevent a recursion with var '_item' as object inside the same object: + + Product Object + ( + [price] => 0 + [quantity] => 0 + [_item] => Product Object + *RECURSION* + ) + + + +- The order respect of template variables's manipulation was improved: + + Example: + ------------- + {= a: 5 =} + + {$a} + + {= a: (# {$a} + 1 #) =} + + {$a} + + {= a: (# {$a} + 1 #) =} + + {$a} + + Output: + ----------- + + 5 + + 6 + + 7 + + +- The template variables's manipulation was improved: + + Example: + --------------- + + {= product: { + name: "banana" + price: 20 + } =} + + Name: {^product.name} + Price: ${#product.price:2.#} + + {= product.price: (# {$product.price} * 2 #) =} + + Double price: ${#product.price:2.#} + + [[product + Current price: {$price} + product]] + + Output: + ---------------- + + Name: banana + Price: $20.00 + + Double price: $40.00 + + Current price: 40 + +- New static methods are added: + + div::issetVar($var, $items) + div::unsetVar($var, $items) + div::setVarValue($var, $value, $items) + div::getVarValue($var, $items) + div::getVars($items) + + Example: + --------------- + product + [1] => product.name + [2] => product.price + ) + +- The method setItem and getItem was improved with detection of complex variable's names: + + Example: + ---------------------- + + array( + "name" => "Banana", + "price" => null + ) + )); + + $tpl->setItem("product.price", 10); + + index.tpl + ------------------- + Name: {$product.name} + Price: ${#product.price:2.#} + + Output + ------------------ + Name: Banana + Price: $10.00 + + +- bugfix in the bodies of multi-replacements +- Changed the name of method multiReplace by parseMultiReplace + + + +- Performance: work remembered! Now the engine can remember some + actions from previous work and increase their speed. - New feature: the macros. -- New feature: the custom sub-parsers. -- The interpretation of aggregate functions was improved. The next example work now. + + A macro is a restricted PHP code inside the templates to facilitate the complex processing + with the advantages of this language. The security is guaranteed. See the next silly example: + + index.php + ---------- + 'Hello world')); + + index.tpl + ------------- + + + {$title} + + Output + ----------- + Hello world + + HELLO WORLD + +- New feature: the custom sub-parsers + + A sub-parser is a parser implmemented by the programmer. For example: + + index.php + -------------- + 'Hello world')); + + index.tpl + ---------------- + + {literal} + + {/literal} + + {$title} + + Ouput + ---------------- + + + Hello world + + + + +- The interpretation of aggregate functions was improved. + The next example work now: + + index.tpl + ------------ + {= products: [ + {name: "Banana", price: 10}, + {name: "Potato", price: 20} + ] =} + + {$products.0.price} + {#products.0.price:2#} + + {$sum:products-price} + {#sum:products-price:2,#} + {%sum:products-price} + + Output + ------------- + 10 + 10.00 + + 30 + 30,00 + 2 + + + - The interpretation of date format was improved. -- New static method anyToStr, for convert mixed value to string based on this rule. -- String is string. -- Boolean is "true" or "false". -- Number is "number". -- Object with __toString() is __toString(). -- Object without __toString() is array. -- Array is count(). + + If you need type the char ":" in the format, and this + char is the separator between var and format, then type + a backslash before ":", like as this: + + {/2012-01-01 00:30:00 : Y-m-d h\:i\:s/} + + In the example the value is "2012-01-01 00:30:00 " and + the format is "Y-m-d h:i:s". + + + +- New static method anyToStr, for convert mixed value to string based on this rule: + - string is string + - boolean is "true" or "false" + - number is "number" + - object with __toString() is __toString() + - object without __toString() is array + - array is count() - Changed the type of unchangeable methods to "final". -- Enabled custom dialect for developers. -- New static method isValidCurrentDialect, for detect error in the definition of current dialect, based on this rule. -- Some tags are required, like as, prefixes, suffixes, beginnings and ends. -- Some tags must be unique, like as, modifiers, else, break, empty, ... + + + +- Enable custom dialect for developers! + + A dialect is defined by the group of constant whose name + begins with DIV_TAG. This dialect is subject to some simple + rules that Div forces to complete for preveer inconsistencies and + infinite loops. + +- New static method isValidCurrentDialect, for detect error in the + definition of current dialect, based on this rule: + - some tags are required, like as, prefixes, suffixes, beginnings and ends. + - some tags must be unique, like as, modifiers, else, break, empty, ... + + + - Created a tool to build dialects. +- Release the 3.9 version + + ## Commits - No commits found. diff --git a/releases/v4.0.0.md b/releases/v4.0.0.md index 953148c..c892225 100644 --- a/releases/v4.0.0.md +++ b/releases/v4.0.0.md @@ -2,14 +2,136 @@ Date: 2013-05-27 ## Description -This release includes: + - Fixed some bugs in locations and conditional parts. -- Created a translator of dialects. Div now have 2 new public methods. -- New feature: template properties. Now you can specify some properties in the template's code, for example, the dialect of the current template. -- New feature: predefined subparsers. Div provide pre-defined sub-parsers, for example, This means that a new instance of div will be created, similar to the loops and the capsules. Other predefined subparsers will be developed in future releases. -- New feature: sub-parser's events. Now in the templates's code you can specify when a sub-parser will be executed: beforeParse, afterInclude or afterParse. Example. -- Improved the conditional parts detection. -- Changed to private some div's properties. +- Created a translator of dialects. Now div have 2 new public methods: + + $tpl = new div('templateWithDialectX.tpl', $data); + + $dialectY = 'json code'; // or associative array + + // Return the translated template + $new_code = $tpl->translateFrom($dialectY); + + // Translate and change the original template + $tpl->translateAndChange($dialectY); + +- New feature: template properties. Now you can specify some properties +in the template's code, for example, the dialect of the current template: + + Example: + + index.tpl + -- + @_DIALECT = smarty.dialect + + {* this is a comment *} + Name: {$name} + + {literal} + {$name} + {/literal} + + {% other %} + + other.tpl + -- + @_DIALECT = twig.dialect + + {{ foo.bar }} + + smarty.dialect + -- + { + 'DIV_TAG_IGNORE_BEGIN': '{literal}', + 'DIV_TAG_IGNORE_END': '{/literal}', + 'DIV_TAG_COMMENT_BEGIN': '{*', + 'DIV_TAG_COMMENT_END': '*}' + } + + twig.dialect + --- + { + 'DIV_TAG_REPLACEMENT_SUFFIX': ' }}', + 'DIV_TAG_MODIFIER_SIMPLE': '{ ' + } + + index.php + --- + 'Peter', + 'foo' => array( + 'bar' => 45 + ) + )); + + Output + --- + Name: Peter + + {$name} + + 45 +- New feature: predefined subparsers. Div provide pre-defined sub-parsers, for example, + {parse}...{/parse}. This example of sub-parser make a pre-proccess of enclosed code. + This means that a new instance of div will be created, similar to the loops + and the capsules. Other predefined subparsers will be developed in future releases. + +- New feature: sub-parser's events. Now in the templates's code you can specify when + a sub-parser will be executed: beforeParse, afterInclude or afterParse. Example: + + index.tpl + --------------------------- + {= name: "Peter" =} + {= products: [ + { + name: "banana", + price: 40 + }, + { + name: "potato", + price: 25 + } + ] =} + + [$products] + {parse:beforeParse} + Name: {$name} + {/parse:beforeParse} + + Product name: {$name} + + {% other %} + [/$products] + + other.tpl + --------------------------- + {parse:beforeParse} + Other name: {$name} + {/parse:beforeParse} + + Output + ---------- + Name: Peter + Product name: banana + Other name: banana + Name: Peter + Product name: potato + Other name: potato + + + +- Improvement of the conditional parts detection + + + +- Change to private some div's properties +- Release 4.0 version + + ## Commits - No commits found. diff --git a/releases/v4.1.0.md b/releases/v4.1.0.md index 5892a62..5e8cafd 100644 --- a/releases/v4.1.0.md +++ b/releases/v4.1.0.md @@ -2,12 +2,18 @@ Date: 2013-05-30 ## Description -This release includes: -- Fixed and improve the algorithm of div::getVarValue() method. -- Fixed the detection of conditional parts. -- Test new version. -- Minor bugs was fixed. -- Improved the detection of date formats. + +- Fix and improve the algorithm of div::getVarValue() method. +- Fix the detection of conditional parts. + + + +- Test new version +- Minor bugs was fixed +- Improvement of the detection of date formats +- Release 4.1 version + + ## Commits - No commits found. diff --git a/releases/v4.2.0.md b/releases/v4.2.0.md index 01252b0..df72e40 100644 --- a/releases/v4.2.0.md +++ b/releases/v4.2.0.md @@ -2,17 +2,90 @@ Date: 2013-06-08 ## Description -This release includes: -- Improved the getRanges() algorithm to cover more cases. Div now continues searching ranges after unclosed tags. -- Improved the parser for ignored parts. -- Improved the parser for includes. -- New feature: template documentation. Now in the comments you can document the template. The documentation sections use @ as a prefix. -- Fixed the getRanges() algorithm. -- Fixed the parser for macros. + +- Improvement of the algorithm of getRanges() to make all the possible one. Now +Div continues searching ranges after unclosed tags. + + - For next template: + + index.tpl + ---------- + {/ + {/div.now/} + + - In previous versions (1.0 - 4.1): + + Output: + ---------- + {/ + {/div.now/} + + - From Div 4.2: + + Output: + ---------- + {/ + 2013-05-31 + + + +- Improvement of the parser of ignored parts +- Improvement of the parser of includes +- New feature: template's documentation. Now in the comments you can +document the template. The documentation's parts have @ as prefix. For example: + + + + To obtain the documentation data: + + $data = div::getDocs(); + + To obtain a readable documentation: + + echo div::getDocsReadable(/* optional template */); + +- Fix the algorithm of getRanges(). +- Fix the parser of macros. - Added a new sub-parser's event: afterReplace. -- Fixed and improved the translator. -- Fixed and improved the parser. -- Improved template documentation. + + +- Fix/improve the translator +- Fix/improve the parser + + + +- Improvement of template's documentation +- Release new version 1.1 of Div Dialect Creator +- Release the version 4.2 + + ## Commits - No commits found. diff --git a/releases/v4.3.0.md b/releases/v4.3.0.md index f275f77..f44c846 100644 --- a/releases/v4.3.0.md +++ b/releases/v4.3.0.md @@ -2,16 +2,166 @@ Date: 2013-06-15 ## Description -This release includes: -- Improved the parser for template's vars: If the value is not valid JSON, it will be considered as a template and will be parsed before decoding. -- Improved the parser for template's variables. Was improved the detection of assignment of variables in any part of the. -- Improved relative include/preprocessed templates. Now the next example works. -- Improved template's variables assignment. Now the next example works. -- Improved the variables's scope: Now the next example works. -- Integration with Google Chrome/Console and Mozilla Firefox/Firebug plugins. Now the engine's messages will be appear in this browsers's features. -- Improved detection of infinite loops in recursive replacements. -- Improved parser and bugs fixes: if foo not existed, widget waits forever. Now the next example works. -- Improved logs's system. + +- Improvement of the parser of template's vars: + If the value is not valid JSON, it will be considered as + a template and will be parsed before decoding. + + See the next sequence: + + 1. Value is not valid JSON: {= digits: [[:0,8:]{$value},[/]9] =} + 2. Value was parsed: {= digits: [0,1,2,3,4,5,6,7,8,9] =} + 3. Now "digits" is an array. + 4. Replacement: {$digits} + + See the difference: + + 1. Value is valid JSON: {= digits: "[[:0,8:]{$value},[/]9]" =} + 2. Value was not parsed: {= digits: "[[:0,8:]{$value},[/]9]" =} + 3. Now "digits" is an string. + 4. Replacement: {$digits} + +- Improvement of the parser of template's variables. Was improved + the detection of assignment of variables in any part of the + JSONs values. For example: + + index.tpl + --------- + + {= cities: ["New York", "Tokyo"] =} + + {= combobox: { + id: "cboCities", + options: $cities + } =} + + {$combobox.options.0} + + Output + --------- + New York + + + +- Improvement of relative include/preprocessed templates. + Now the next example works: + + index.tpl + ------------------------- + {% folder/tpl1 %} + + /folder/tpl1.tpl + ------------------------- + {% folder2/tpl2 %} + + /folder1/folder2/tpl2.tpl + ------------------------- + {% tpl3 %} + + /folder1/folder2/tpl3.tpl + ------------------------- + Hello + + Ouput + ------------------------- + Hello + +- Improvement of template's variables assignment. + Now the next example works: + + index.tpl + ------------------------- + {= position: "absolute" =} + + {?( "{$position}" == "absolute" )?} + {= absolute: true =} + @else@ + {= absolute: false =} + {/?} + + ?$absolute YES $absolute? + + Ouput + ------------------------- + YES + +- Improvement of the variables's scope: + Now the next example works: + + index.tpl + ---------------- + {= foo: true =} + {= bar: [1,2,3] =} + + ?$foo + YES + $foo? + + [$bar] + {= foo: (# {$value} > 1 #) =} + ?$foo + YES + @else@ + NO + $foo? + [/$bar] + + {$foo} + + Output + -------------- + YES + + NO + + YES + + YES + + true + + +- Integration with Google Chrome/Console and Mozilla Firefox/Firebug plugins. + Now the engine's messages will be appear in this browsers's features. + +- Improvement of detection of infinite loops in recursive replacements: + + index.tpl + ------------- + {= bar: {${$e}} =} + {= e: 'bar'} =} + + {$bar} + + Output + ------------- + [[ FATAL ERROR ]] WAS DETECTED AN INFINITE LOOP IN RECURSIVE REPLACEMENT OF $foo. + +- Improvement of parser and bugs fixes: if foo not existed, widget waits forever. + Now the next example works: + + index.tpl + ------------------ + {= widget: 45 =} + + {?( "{$foo}" == "a" )?} + {= bar: 5 =} + {/?} + + {$widget} + + Output + ------------------ + 45 + + Solved! + + + +- Improvement of logs's system +- Release 4.3 version + + ## Commits - No commits found. diff --git a/releases/v4.4.0.md b/releases/v4.4.0.md index 05b96df..4ed6d34 100644 --- a/releases/v4.4.0.md +++ b/releases/v4.4.0.md @@ -2,12 +2,21 @@ Date: 2013-07-27 ## Description -This release includes: -- Improved the modifier "escape single quotes" (\') to "escape single/double quotes" (\"). -- Improved default documentation's template. -- Bug fix the translator. -- New feature: Multi template sources (based on include_path PHP setting). -- Bug fixes. + +- Improvement of the modifier "escape single quotes" (\') + to "escape single/double quotes" (\"). +- Improvement of default documentation's template. + + + +- bugfix the translator +- New feature: Multi template sources (based on include_path PHP setting) + + +- bugfixs! +- Release 4.4 version + + ## Commits - No commits found. diff --git a/releases/v4.5.0.md b/releases/v4.5.0.md index 6432793..286b3f9 100644 --- a/releases/v4.5.0.md +++ b/releases/v4.5.0.md @@ -2,40 +2,283 @@ Date: 2014-12-01 ## Description -This release includes: -- Decrease of priority in parser's specialchars. -- An important bug was fixed: the memory in the loops. -- Bug fix: div::getFileContents(). -- Improved global design vars in loops and capsules. -- Bug fix: div::fileExists and wrong include paths calculation. -- Memory fixed. -- Some bug fixes. -- Added new important security feature: setup literals items/vars, for prevent injections. -- Allowed is_array PHP function in macros. -- New method for add literal vars in PHP: div::addLiteral();. -- Fixed macros parsing when a previous template var never match. -- Fixed the memory in the loops. -- Security fix: prevent obtrusive code in method calls. Now next code doesn't work. -- New feature for preprocessed templates: specific data. -- Bug fix: Parse pre-processed templates with all items/vars (Div doesn't know the future). -- Bug fix: Adding items to array in templates. -- Bug fix: Don't set item var as design var in div::parseData();. -- Bigfix: Save sections of loops and capsules when makeItAgain(); (Div doesn't know the future). -- Big fix: Set the priority to inline data in pre-processed templates above global design vars. -- Bug fixed and improved - Parsing orphan's parts while checksum not change. Do it because the orphans's parts stop the parser and the results are ugly. -- Bug fix: Parsing macros inside preprocessed templates. New argument $min_level for parse() method. -- Added new allowed functions in macros, formulas and expressions: array_keys get_object_vars is_object. -- Allowed T_BREAK token in macros for foreach and other loops. Then, the follow macro is an error. -- New feature: advanced options/params for includes. -- Bug fix: Preparing allowed methods before execute the macros. -- Bug fix in parsePreprocessed() when $pdata is null. -- Bug fix with number formats inside loops. -- Bug fix parseData() vs parseMatch() logical order. -- New setup var: div.clear_locations (= true by default). This means that the locations will be clear or not at the end (parse_level = 0). Then, the components are more flexible with **pre-processed templates**. -- Improved performance changing $vars with __temp['vars'] var in parseMacros(); because because get_defined_vars return also vars. -- Prevented infinite loops in div::cop();. -- Improved div::isValidPHPCode(). -- Some bug fixes. + +- Decrease of priority in parser's specialchars + + + +- An important bug was fixed: the memory in the loops: + + In div 4.4 dont't work: + + index.php + ---- + array("Havana", "Tokyo"))); + + index.tpl + ---- + {= foo: [ + { title: "Cities", + content: '{% cities.tpl %}' + } + ] =} + + {% layout.tpl %} + + layout.tpl + ----- + ?$foo + [$foo] +

        {$title}

        + {$content}
        + [/$foo] + $foo? + + cities.tpl + ----- + ?$cities + [$cities] + {$value} + [/$cities] + @else@ + No cities + $cities? + + Output (wrong!) + ----- +

        Cities

        + No cities
        + + Output (great in 4.5) + ----- +

        Cities

        + Havana Tokio
        + + + +- bugfix: div::getFileContents() + + + +- Improvement of global design vars in loops and capsules + + + +- bugfix: div::fileExists and wrong include paths calculation + + + +- Memory fixed! + + + +- Some bugfixs +- Add new important security feature: setup literals items/vars, for prevent injections! + +Example: + +index.tpl +--------------- +{= div.literals: ["text1", "text2"] =} + +{$text1} + +{$text2} + +{$text3} + +index.php +--------------- +echo new div('index.tpl', array( + 'text1' => '{/ignore}[:1,5:] {$value} [/]{ignore}', // I am being about deceiving the security + 'text2' => '[:1,100;] text to repeat [/]', + 'text3' => '[:1,3;] some [/]' +)); + +output +--------------- +[:1,5;] {$value} [/] +[:1,100;] text to repeat [/] +some some some + + + +- Allow is_array PHP function in macros +- New method for add literal vars in PHP: div::addLiteral(); + + + +- Fix macros parsing when a previous template var never match + + + +- Fix the memory in the loops + + + +- Security fix: prevent obtrusive code in method calls. Now next code dont work: + +{= content: ->getPage(file_put_contents('some.txt','some text')) =} + + + +- New feature for preprocessed templates: specific data + + Syntax: + + {%% tpl_file: data %%} + + data is: json, name of var or filename with json + + Example: + + Now is more simple for build the components: + + index.tpl + ------------ + {%% form: { + action: "login.php", + method: "post.php", + fields: [ + { + type: "text", + name: "user", + label: "User" + },{ + type: "password", + name: "pass", + label: "Password" + } + ], + submit: { + value: "login", + name: "btnLogin" + } + } %%} + + form.tpl + ------------ +
        + [$fields] + {$label}:
        +
        + [/$fields] + +
        + + + +- bugfix: Parse pre-processed templates with all items/vars (Div doesn't know the future) + + + +- bugfix: Adding items to array in templates + +{= somearray[]: "new item" =} + +- bugfix: Don't set item var as design var in div::parseData(); + + + +- bigfix: Save sections of loops and capsules when makeItAgain(); (Div doesn't know the future) + + +- big fix: Set the priority to inline data in pre-processed templates above global design vars +--- +- bugfix/improve - Parsing orphan's parts while checksum not change. Do it because the orphans's parts stop the parser and the results are ugly. +--- +- bugfix: Parsing macros inside preprocessed templates. New argument $min_level for parse() method. +- Add new allowed functions in macros, formulas and expressions: `array_keys` `get_object_vars` `is_object` +- new static method `div::div():` + +index.php + +```php + "value1")); +``` + +- Allow T_BREAK token in macros for foreach and other loops. Then, the follow macro is an error: +index.tpl + +```php + +``` + +Output +```shell +Fatal error: Cannot break/continue 1 level in div.php: eval()'d code on line 1 +``` +--- +- new feature: advanced options/params for includes + +index.tpl +``` +{% subtpl: { + from: "", + to: "", + offset: 2, + limit: 1 +} %} +``` + +subtpl.tpl + +``` +Any text... + +Some text 1 + +Any text... + +Some text 2 + +Any text +``` + +- bugfix: Preparing allowed methods before execute the macros +--- +- bug fix in `parsePreprocessed()` when $pdata is null +- bug fix with number formats inside loops +--- +- bugfix `parseData()` vs `parseMatch()` logical order +--- +- new setup var: `div.clear_locations` (= true by default). This means that the locations will be clear or not at the end (parse_level = 0). Then, the component are more flexible with **pre-processed templates**: + +comp.tpl + +```html +(( before )) (( after )) +``` + +index.tpl +```html +{%% comp: { + type: "text", + name: "first_name", + div: { + clear_locations: false + } +} %%} + + + +{{before before}} +{{after after}} +``` + +--- +- improve performance changing $vars with `__temp['vars']` var in `parseMacros();` because because `get_defined_vars` return also `vars` +- prevent infinite loops in `div::cop();` +--- +- improve `div::isValidPHPCode()` +--- +- some bug fixes +- Release 4.5 version +--- ## Commits - No commits found. diff --git a/releases/v4.6.0.md b/releases/v4.6.0.md index cb6339f..9b8e027 100644 --- a/releases/v4.6.0.md +++ b/releases/v4.6.0.md @@ -2,8 +2,9 @@ Date: 2015-12-11 ## Description -This release includes: -- Bug fix in div class constructor. +- Bugfix in div class constructor +- Release 4.6 version +--- ## Commits - No commits found. diff --git a/releases/v4.7.0.md b/releases/v4.7.0.md index 4ace15c..c30986a 100644 --- a/releases/v4.7.0.md +++ b/releases/v4.7.0.md @@ -2,10 +2,38 @@ Date: 2015-12-19 ## Description -This release includes: -- Some bug fixes, thanks to gracix and Takefumi Ota. -- Improved template's vars and OOP: now you can access to a public method of any object. -- Several tests. +- [starting release 4.7] +- some bug fixes, thanks to `gracix` and `Takefumi Ota` +- Improve template's vars and OOP: now you can access to a public method of any object. + +Example: + +index.php + +```php +first_name.' '.$this->last_name; + } + ... +} + +echo new div('index.tpl', array("person" => new Person(...))); +``` + +index.tpl + +``` +{= fullname: ->person.getFullName() =}` +The full name is {$fullname} +``` +--- +- several tests +- Release 4.7 version + ## Commits - No commits found. diff --git a/releases/v4.8.0.md b/releases/v4.8.0.md index d23fc40..bbc8f04 100644 --- a/releases/v4.8.0.md +++ b/releases/v4.8.0.md @@ -2,13 +2,51 @@ Date: 2016-10-10 ## Description -This release includes: -- Added new feature for dialects: DIV_TAG_VAR_MEMBER_DELIMITER. This dialect's constant define a delimiter for variable's members. -- Improved dialect translator div::translateFrom. -- Some bug fixes. -- Updated documentation. -- Review example. -- Several tests. +- add new feature for dialects: DIV_TAG_VAR_MEMBER_DELIMITER. This dialect's constant define a delimiter for variable's members. For example: + +by default you use: +``` +{$person.name} +``` + +but now you can do... + +index.php +```php +'); + + include "div.php"; + + echo new div("index.tpl", array( + 'person' => array( + 'name' => 'Peter', + 'child' => array( + 'name' => 'eli' + ) + ) + )); +``` +index.tpl +``` +{$person->child->name} +{$person->name} +``` + +TODO: improve dialect creator tool +TODO: check dialect translator method div::translateFrom() + + +- improved dialect translator `div::translateFrom` +- some bug fixes +- update documentation +--- +- review example +--- +- Several tests +- Release 4.8 version +--- ## Commits - No commits found. diff --git a/releases/v4.9.0.md b/releases/v4.9.0.md index 09690e1..0684000 100644 --- a/releases/v4.9.0.md +++ b/releases/v4.9.0.md @@ -2,10 +2,44 @@ Date: 2016-12-22 ## Description -This release includes: -- Added new default subparser join. -- Important bug fix/improvement: access to parent loop. -- PHP 7 Compatibility check. +- add new default subparser join + +Syntax: +``` +{join} varname | delimiter {/join} +``` + +index.tpl +``` +{= tags: ['a','b', 'c'] =} +{join} tags |, {/join} +{join} tags |,{/join} +{join} tags {/join} +``` + +Output: +``` +a, b, c +a,b,c +abc +``` +--- +- important bugfix/improvement: access to parent loop + +``` +[$parentloop] parent => + [$childloop] child => + Parent key: {$parent._key} + Child key: {$_key} or {$child._key} + [/$childloop] +[/$parentloop] +``` + +- TODO: test & release + +- PHP 7 Compatibility check +- Release 4.9 version +--- ## Commits - No commits found. diff --git a/releases/v5.1.0.md b/releases/v5.1.0.md index a1d2b3f..04066f1 100644 --- a/releases/v5.1.0.md +++ b/releases/v5.1.0.md @@ -2,36 +2,291 @@ Date: 2019-07-22 ## Description -This release includes: -- Some bug fixes. -- New variable for inline data of preprocessed templates: div.standalone, by default is FALSE. This means that the "foo" variable will not be passed to the template pre-processor. That is, the variables in the parent template will be ignored and only the data specified in the line will be used. +- Some bugfixs +- New variable for inline data of preprocessed templates: `div.standalone`, by default is FALSE. + This means that the "foo" variable will not be passed to the template pre-processor. That is, the variables in the parent template will be ignored and only the data specified in the line will be used. + +``` +{= foo: value =} +{%% block.tpl: { + div: { + standalone: true + } +} %%} +``` + + This better facilitates the recursive inclusion of templates, useful in generation of source code and other hierarchies like XML, HTML, JSON, etc. + - Do not include anything within the conditional blocks if the conditions have not been resolved. This check prevent infinite loops. -- Priority change for items over filesystem when include o preprocess templates. To force load data from external file, please type the path or full path (ex: block.json) var1: "value1" var2: "value2" } =}. -- Improved the translator. Now you can translate from and to other dialects. -- Fixed dynamic include's paths inside loops. -- Fixed and improve getAuxiliaryEngine. -- Fixed a bug with getAuxiliaryEngine (clone vs assignment). -- Added some new system vars. -- Div.class_name: the name of current invoked class ('div' or child of 'div'). -- Div.super_class_name: the name of super parent of current invoked class name (normally is 'div'). -- Code review. -- Changed scope of ->loadTemplateProperties() to public. -- Other minor fixes. -- Automatic update of template source code after prepareDialect() ... -- ... && new param for ->prepareDialect() for disable automatic update. -- Re-thinking the change in **June 10, 2013** about invalid JSON in assignments. Is important the dynamic path of JSON files. -- Important improvement for loading JSON data from relative path in template variable's assignment. -- Bug fix on constructor, when div var is an object and not an array. -- Added file_exists as allowed function. -- Added in_array as allowed function. -- Optimize the code: change "is_null" as "=== null", because is_null is 250ns slower (in favor of PHP 5). -- Bug fix: better resolution of tags with empty suffix. In this example "list.filter" is a substring of "list.filter.category", and then exists resulting unexpected code if $list.filter is false. -- Important change!: Now NULLs vars exists and are replaced with empty strings. -- Important change!: Fix scope of pre-processed templates inside loops. -- Divengine namespace. -- Bug fix: Fix scope of standalone pre-processed templates. This fix prevents infinite loops and is useful for recursive pre-process in a component based design. -- Bug fix in div::scanMatch. -- Improved: Better resolution of default template for child classes of div, using Reflection. + +```php + ?$block + {%% block: {...} %%} <-- wait for block question results + $block? +``` + +- Priority change for items over filesystem when include o preprocess templates. To force load data from external file, please type the path or full path (ex: block.json) +``` +{= block: { + var1: "value1" + var2: "value2" +} =} +``` + + Take the block value + `{%% tpl: block %%}` + + Take json from external file + `{%% tpl: block.json %%}` + +--- +- Improve the translator. Now you can translate from and to other dialects. + +```php +$tpl = new div("index.tpl", []); +``` + +Translate from other dialect to current dialect: + +```php +$tpl->translateFrom($dialectFrom); +``` + + Translate from current dialect to other dialect: + +```php +$tpl->translateTo($dialectFrom); +``` + +Translate from any dialect to any dialect: + +```php +$tpl->translate($dialectFrom, $dialectTo, $src, $items); +``` + +Maybe you need prepare the current dialect first: + +```php +prop = $tpl->getTemplateProperties(); +$tpl->__src = $tpl->prepareDialect(null, $prop); +``` +--- +- Fix dynamic include's paths inside loops +``` +[$blocks] + {% blocks/block-{$id}.tpl %} +[/$blocks] +``` +--- +- Fix and improve getAuxiliaryEngine +--- +- Fix a bug with `getAuxiliaryEngine` (clone vs assignment) +- Add some new system vars + - `div.class_name`: the name of current invoked class ('div' or child of 'div') + - `div.super_class_name`: the name of super parent of current invoked class name (normally is 'div') +- Code review +--- +- Change scope of `->loadTemplateProperties()` to public +- Other minor fixes +- Automatic update of template source code after `prepareDialect()` ... +- ... && new param for `->prepareDialect()` for disable automatic update +--- +- Re-thinking the change in **June 10, 2013** about invalid JSON in assignments. Is important the dynamic path of JSON files: + +``` +{= i18n: i18n/{$lang}.json =} +``` + +`"i18n/{$lang}.json"` without quotes is invalid JSON + +Then, don't use quotes: +``` +{= i18n: "i18n/{$lang}.json" =} +``` + +- Important improvement for loading JSON data from relative path in template variable's assignment: + +``` + relative --> + | + v + /app/site/view/i18n/en/messages.json + ^ + | + replacement result +``` + +/app/site/view/page.tpl + +``` +{= lang: "en" =} +{= i18n: i18n/{$lang}/messages.json =} + +{$i18n.message1} +``` + +/app/site/view/i18n/en/messages.json +``` +{ + message1: "Hello" +} +``` + +Output: +``` +Hello +``` +--- +- `bugfix` on constructor, when div var is an object and not an array +- Add file_exists as allowed function +- Add in_array as allowed function +--- +- Optimize the code: change "is_null" as "=== null", because is_null is 250ns slower (in favor of PHP 5) + +In PHP 7 (phpng), is_null is actually marginally faster than `===`, although the performance difference between the two is far smaller. + +``` +PHP 5.5.9 +is_null - float(2.2381200790405) +=== - float(1.0024659633636) +=== faster by ~100ns per call + +PHP 7.0.0-dev (built: May 19 2015 10:16:06) +is_null - float(1.4121870994568) +=== - float(1.4577329158783) +is_null faster by ~5ns per call +``` +--- +- `bugfix`: better resolution of tags with empty suffix. In this example "list.filter" is a substring of "list.filter.category", and then exists resulting unexpected code if $list.filter is false + +TPL +``` +?$list.filter + AAA + ?$list.filter.category + BBB + $list.filter.category? + CCC +$list.filter? +``` + +OUTPUT +``` +?$list.filter + AAA +``` + +The fix was for other similar situations in div::getBlockRanges(). +The stop chars are the same in favor of text plain and XML family: + +```php +$stop_chars = ["<", ">", ' ', "\n", "\r", "\t"]; +``` +--- +- important change!: Now NULLs vars exists and are replaced with empty strings + +PHP +```php +echo new div('Var is: {$var}', ['var' => null]); +``` + +OUTPUT before this change: +``` +Var is: {$var} +``` + +OUTPUT after this change: +``` +Var is: +``` + +- `important change!`: Fix scope of pre-processed templates inside loops + +Do not pre-process anything within the loops blocks if the loops have not been resolved +The following code did not work as expected, because the pre-process was executed before doing the loop. So the `$col` variable did not exist and logic of the template will be broken. + +``` +[$cols] col => + {%% element: { + tag: "td", + attrs: $col.attrs, + inner: $col.content + } %%} +[/$cols] +``` +--- +- new feature for custom engine: + +MyComponent.php +```php +MyComponent extends div { + .... +} +``` + +index.tpl: +``` +{%% component: { + div: { + engine: "MyComponent" + }, + someProperty: "bla" +} %%} +``` +--- +- Divengine namespace! +- `bugfix`: Fix scope of standalone pre-precessed templates. This fix prevent infinite loops and is util for recursive pre-process in a component based design. + +index.tpl +``` +{= foo: "bar" =} +{%% component: { + div: {standalone: true}, // ignore parent scope + zoo: "monkey" +} %%} +``` + +component.tpl +``` +{$zoo} +{$foo} +``` +--- +- `bugfix` in div::scanMatch +--- +- `release` version 5.1.0 +- `improvement`: Better resolution of default template for child classes of div, using Reflection! + +**/some/folder/in/the/end/of/the/world/Page.tpl** +``` +Hello people +``` + +**/some/folder/in/the/end/of/the/world/Page.php** +```php + + {= component.div.standalone: true =} + {%% cmp: component %%} + [/$components] +$components? + +?$location {$location}}} $location? +{/strip} +``` + +__Button.tpl__ +``` + +``` + +__Page.tpl__ +```html +

        Buttons

        +(( top )) +

        Click on the buttons:

        +(( bottom )) + +

        Fruits

        +(( fruits )) +``` + +__index.php__ +```php + "welcomePage", + "face" => "{% Page2 %}", + "components" => [ + [ + "face" => "{% Button %}", + "location" => "top", + "caption" => "Click me", + "icon" => '*' + ], + [ + "face" => "{% Button %}", + "location" => "bottom", + "caption" => "Click me again", + "icon" => '#' + ], + [ + "face" => "
          (( items ))
        ", + "location" => "fruits", + "components" => array_map(function ($caption) { + return [ + "face" => "
      1. {$caption}
      2. ", // or "
      3. {\$caption}
      4. " :D + "location" => "items" + ]; + }, ["Banana", "Apple", "Orange"]) + + ] + ] + ] +); +``` + --- ## Commits - No commits found. diff --git a/releases/v5.1.3.md b/releases/v5.1.3.md index ce0b239..484e546 100644 --- a/releases/v5.1.3.md +++ b/releases/v5.1.3.md @@ -2,9 +2,10 @@ Date: 2019-08-22 ## Description -This release includes: -- Fixed resolution of templates path for win and *nix OS. -- Fixed the relative path of included templates inside loop. +- `release` version 5.1.3 +- `fix` resolution of templates path for win and *nix OS +- `fix` the relative path of included templates inside loop +--- ## Commits - No commits found. diff --git a/releases/v5.1.4.md b/releases/v5.1.4.md index c9af59b..434a746 100644 --- a/releases/v5.1.4.md +++ b/releases/v5.1.4.md @@ -2,8 +2,9 @@ Date: 2019-08-23 ## Description -This release includes: -- New method div::getVersion(). +- `release` version 5.1.4 +- new method div::getVersion() +--- ## Commits - No commits found. diff --git a/releases/v5.1.5.md b/releases/v5.1.5.md index 3d9a53e..52ec09e 100644 --- a/releases/v5.1.5.md +++ b/releases/v5.1.5.md @@ -2,8 +2,9 @@ Date: 2019-09-21 ## Description -This release includes: -- Fixed div::varExists() method. +- `release` version 5.1.5 +- `fix` div::varExists() method +--- ## Commits - No commits found. diff --git a/releases/v5.1.6.md b/releases/v5.1.6.md index 00cde86..381687c 100644 --- a/releases/v5.1.6.md +++ b/releases/v5.1.6.md @@ -2,8 +2,9 @@ Date: 2020-02-11 ## Description -This release includes: -- Minor fix: Array and string offset access syntax with curly braces is deprecated. +- `minor fix`: Array and string offset access syntax with curly braces is deprecated +- `release` version 5.1.6 +--- ## Commits - No commits found. diff --git a/releases/v6.0.0.md b/releases/v6.0.0.md index 24bfcbf..d1d7a92 100644 --- a/releases/v6.0.0.md +++ b/releases/v6.0.0.md @@ -2,7 +2,7 @@ Date: 2023-12-24 ## Description -This release moves the project forward to PHP 8.x and introduces PHPStan checks at level 3. +- Moving forward to PHP 8.x && phpstan checks level 3 ## Commits - No commits found. diff --git a/releases/v6.0.1.md b/releases/v6.0.1.md index 3863459..65fe90f 100644 --- a/releases/v6.0.1.md +++ b/releases/v6.0.1.md @@ -2,7 +2,8 @@ Date: 2024-01-26 ## Description -This release improves `div::cop` with Reflection and strict mode, and adds unit tests. +- Improvements to `div::cop` with Reflection and strict modes +- Unit tests ## Commits - No commits found. diff --git a/releases/v6.1.3.md b/releases/v6.1.3.md index 70c041c..be34ef7 100644 --- a/releases/v6.1.3.md +++ b/releases/v6.1.3.md @@ -5,6 +5,7 @@ Date: 2026-02-07 This release focuses on documentation clarity and release tooling. It refines the engine overview and parsing behavior guidance, improves release note generation logic, and aligns workflow configuration with the current versioning and release process. ## Commits +- [chore(release): update release notes for versions v1.1.0 to v6.1.3](https://github.com/divengine/div/commit/ca34786a025838f841ad76632665f2a23ebfa04a) - [Update documentation: enhance the overview and clarify engine behavior and core operations](https://github.com/divengine/div/commit/6e92000055dc530d3f0b05622f5b7dc6ee2bf1be) - [Update documentation: add notes on parsing behavior, loop control, and engine setup variables](https://github.com/divengine/div/commit/756a5c835a86eb5dd1a57400cd108359a4aaa7c3) - [Update release notes generation to exclude merge and changelog update commits](https://github.com/divengine/div/commit/bddbb0fb97e7d39b16aca5d0c4e6bfcae9711d6b) From 4eb5fc37c9a96fc922eb7d85e18092290766f05c Mon Sep 17 00:00:00 2001 From: rafageist Date: Sun, 8 Feb 2026 12:34:07 -0300 Subject: [PATCH 8/9] chore(release): update release notes --- README.md | 2 - docs/01.07 Related topics.md | 2 +- docs/01.13 The div class.md | 4 +- docs/02.04 Special replacements.md | 2 +- ...ntent like an object (intelligent data).md | 18 +- docs/README.md | 2 +- releases/CHANGELOG.md | 3260 ----------------- releases/v1.1.0.md | 4 + releases/v1.2.0.md | 21 +- releases/v1.3.0.md | 4 + releases/v1.4.0.md | 17 +- releases/v1.5.0.md | 9 +- releases/v1.6.0.md | 9 +- releases/v1.7.0.md | 18 +- releases/v1.8.0.md | 35 +- releases/v1.9.0.md | 193 +- releases/v2.0.0.md | 50 +- releases/v2.1.0.md | 231 +- releases/v2.2.0.md | 381 +- releases/v2.3.0.md | 139 +- releases/v2.4.0.md | 35 +- releases/v2.5.0.md | 27 +- releases/v2.6.0.md | 73 +- releases/v2.7.0.md | 28 +- releases/v2.8.0.md | 79 +- releases/v2.9.0.md | 141 +- releases/v3.0.0.md | 75 +- releases/v3.1.0.md | 27 +- releases/v3.2.0.md | 56 +- releases/v3.3.0.md | 6 +- releases/v3.4.0.md | 49 +- releases/v3.5.0.md | 112 +- releases/v3.6.0.md | 132 +- releases/v3.7.0.md | 412 ++- releases/v3.8.0.md | 6 +- releases/v3.9.0.md | 511 +-- releases/v4.0.0.md | 239 +- releases/v4.1.0.md | 10 +- releases/v4.2.0.md | 152 +- releases/v4.3.0.md | 260 +- releases/v4.4.0.md | 16 +- releases/v4.5.0.md | 428 ++- releases/v4.6.0.md | 6 +- releases/v4.7.0.md | 26 +- releases/v4.8.0.md | 64 +- releases/v4.9.0.md | 51 +- releases/v5.1.0.md | 418 ++- releases/v5.1.1.md | 5 + releases/v5.1.2.md | 74 +- releases/v5.1.3.md | 6 +- releases/v5.1.4.md | 6 +- releases/v5.1.5.md | 6 +- releases/v5.1.6.md | 6 +- releases/v6.0.0.md | 3 + releases/v6.0.1.md | 3 + releases/v6.1.0.md | 3 + releases/v6.1.1.md | 3 + releases/v6.1.2.md | 3 + releases/v6.1.3.md | 3 + 59 files changed, 2772 insertions(+), 5189 deletions(-) delete mode 100644 releases/CHANGELOG.md diff --git a/README.md b/README.md index 16aed4e..bf8abdb 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,5 @@ For complete guides, usage examples, and advanced topics, please visit the [proj If you find something missing or have improvements, feel free to contribute directly to the Wiki! ---- - Powered by [Divengine Software Solutions](https://divengine.com) diff --git a/docs/01.07 Related topics.md b/docs/01.07 Related topics.md index e2521db..f160a96 100644 --- a/docs/01.07 Related topics.md +++ b/docs/01.07 Related topics.md @@ -7,4 +7,4 @@ [[04 Mechanisms]] [[05 Appendixes]] -See also [CHANGELOG](../releases/CHANGELOG.md). +See also [Release notes](../releases/README.md). diff --git a/docs/01.13 The div class.md b/docs/01.13 The div class.md index 2c2604e..9c221f7 100644 --- a/docs/01.13 The div class.md +++ b/docs/01.13 The div class.md @@ -1,6 +1,6 @@ # 1.13 The div class -All engine functionality is provided through the div class. If your project already defines a class named div, you can rename the Div class or use a namespace alias. +All engine features are provided through the div class. If your project already defines a class named div, you can rename the Div class or use a namespace alias. ## 4.1 Setup and namespace @@ -58,4 +58,4 @@ echo new div('index.tpl', 'index.json'); Related topics: -[[02.45 Ignore specific variables (the third parameter of constructor)]] \ No newline at end of file +[[02.45 Ignore specific variables (the third parameter of constructor)]] diff --git a/docs/02.04 Special replacements.md b/docs/02.04 Special replacements.md index e70b1d7..e8d3e98 100644 --- a/docs/02.04 Special replacements.md +++ b/docs/02.04 Special replacements.md @@ -25,5 +25,5 @@ Output ```html Hello Peter - Today is 2013-07-24 + Today is 2013-07-24 ``` \ No newline at end of file diff --git a/docs/02.42 Content like an object (intelligent data).md b/docs/02.42 Content like an object (intelligent data).md index 841caf7..dc2f9ac 100644 --- a/docs/02.42 Content like an object (intelligent data).md +++ b/docs/02.42 Content like an object (intelligent data).md @@ -30,7 +30,7 @@ echo new div('index.tpl', new MyData(["A","B","C","D"])); index.tpl -``` +```div {= data: ->implode() =} {$data} @@ -38,7 +38,7 @@ index.tpl Output -``` +```text A,B,C,D ``` @@ -68,7 +68,7 @@ echo new div('index.tpl', ['name' => new MyString('peter')]); index.tpl -``` +```div [[name {$value} @@ -80,7 +80,7 @@ name]] Output -``` +```text peter PETER ``` @@ -89,14 +89,14 @@ PETER index.tpl -``` +```div {= up: ->name.upper() =} {$up} ``` Output -``` +```text PETER ``` @@ -130,7 +130,7 @@ echo new div('index.tpl', [ index.tpl -``` +```div [$people] {= complete_name: ->getName() =} @@ -143,7 +143,7 @@ index.tpl Output -``` +```text First name: John Last name: Nash Complete name: John Nash @@ -157,4 +157,4 @@ Last name: Fresco Complete name: Jacque Fresco ``` -Related topic: [[02.43 Hooks]]. \ No newline at end of file +Related topic: [[02.43 Hooks]]. diff --git a/docs/README.md b/docs/README.md index bc52c9f..7d9f091 100644 --- a/docs/README.md +++ b/docs/README.md @@ -129,6 +129,6 @@ composer upgrade - [[04 Mechanisms]] - [[05 Appendixes]] -See also [CHANGELOG](../releases/CHANGELOG.md). +See also [Release notes](../releases/README.md). #templates diff --git a/releases/CHANGELOG.md b/releases/CHANGELOG.md deleted file mode 100644 index 33ca774..0000000 --- a/releases/CHANGELOG.md +++ /dev/null @@ -1,3260 +0,0 @@ -Jan 26, 2023 -- Improvements to `div::cop` with Reflection and strict modes -- Unit tests ---- -Dec 24, 2023 -- Moving forward to PHP 8.x && phpstan checks level 3 ---- -Feb 11, 2020 -- `minor fix`: Array and string offset access syntax with curly braces is deprecated -- `release` version 5.1.6 ---- -Sep 21, 2019 -- `release` version 5.1.5 -- `fix` div::varExists() method ---- -Ago 23, 2019 -- `release` version 5.1.4 -- new method div::getVersion() ---- -Ago 22, 2019 -- `release` version 5.1.3 -- `fix` resolution of templates path for win and *nix OS -- `fix` the relative path of included templates inside loop ---- -Ago 21, 2019 -- `release` version 5.1.2 -- `fix` orphan conditional parts -- `fix` standalone preprocessed templates -- Now this example works! - -__cmp.tpl__ - -This is a generic template for create visual components. Each component have a *face* or *content*, and more *child components*. Each child can located in the face of their parent. The template self call recursively. - -``` -{strip} -?$location {{{$location} $location? - -?$face {$face} $face? - -?$components - [$components] component => - {= component.div.standalone: true =} - {%% cmp: component %%} - [/$components] -$components? - -?$location {$location}}} $location? -{/strip} -``` - -__Button.tpl__ -``` - -``` - -__Page.tpl__ -```html -

        Buttons

        -(( top )) -

        Click on the buttons:

        -(( bottom )) - -

        Fruits

        -(( fruits )) -``` - -__index.php__ -```php - "welcomePage", - "face" => "{% Page2 %}", - "components" => [ - [ - "face" => "{% Button %}", - "location" => "top", - "caption" => "Click me", - "icon" => '*' - ], - [ - "face" => "{% Button %}", - "location" => "bottom", - "caption" => "Click me again", - "icon" => '#' - ], - [ - "face" => "
          (( items ))
        ", - "location" => "fruits", - "components" => array_map(function ($caption) { - return [ - "face" => "
      5. {$caption}
      6. ", // or "
      7. {\$caption}
      8. " :D - "location" => "items" - ]; - }, ["Banana", "Apple", "Orange"]) - - ] - ] - ] -); -``` - --- - -Jul 22, 2019 -- `release` version 5.1.1 -- `improvement` support namespaces of div's child -- `release` version 5.1.0 -- `improvement`: Better resolution of default template for child classes of div, using Reflection! - -**/some/folder/in/the/end/of/the/world/Page.tpl** -``` -Hello people -``` - -**/some/folder/in/the/end/of/the/world/Page.php** -```php - -``` ---- -Jul 2, 2019 -- new feature for custom engine: - -MyComponent.php -```php -MyComponent extends div { - .... -} -``` - -index.tpl: -``` -{%% component: { - div: { - engine: "MyComponent" - }, - someProperty: "bla" -} %%} -``` ---- -Jun 27, 2019 -- important change!: Now NULLs vars exists and are replaced with empty strings - -PHP -```php -echo new div('Var is: {$var}', ['var' => null]); -``` - -OUTPUT before this change: -``` -Var is: {$var} -``` - -OUTPUT after this change: -``` -Var is: -``` - -- `important change!`: Fix scope of pre-processed templates inside loops - -Do not pre-process anything within the loops blocks if the loops have not been resolved -The following code did not work as expected, because the pre-process was executed before doing the loop. So the `$col` variable did not exist and logic of the template will be broken. - -``` -[$cols] col => - {%% element: { - tag: "td", - attrs: $col.attrs, - inner: $col.content - } %%} -[/$cols] -``` ---- -Jun 14, 2019 -- `bugfix`: better resolution of tags with empty suffix. In this example "list.filter" is a substring of "list.filter.category", and then exists resulting unexpected code if $list.filter is false - -TPL -``` -?$list.filter - AAA - ?$list.filter.category - BBB - $list.filter.category? - CCC -$list.filter? -``` - -OUTPUT -``` -?$list.filter - AAA -``` - -The fix was for other similar situations in div::getBlockRanges(). -The stop chars are the same in favor of text plain and XML family: - -```php -$stop_chars = ["<", ">", ' ', "\n", "\r", "\t"]; -``` ---- -Sep 20, 2018 -- Optimize the code: change "is_null" as "=== null", because is_null is 250ns slower (in favor of PHP 5) - -In PHP 7 (phpng), is_null is actually marginally faster than `===`, although the performance difference between the two is far smaller. - -``` -PHP 5.5.9 -is_null - float(2.2381200790405) -=== - float(1.0024659633636) -=== faster by ~100ns per call - -PHP 7.0.0-dev (built: May 19 2015 10:16:06) -is_null - float(1.4121870994568) -=== - float(1.4577329158783) -is_null faster by ~5ns per call -``` ---- -Aug 19, 2018 -- `bugfix` on constructor, when div var is an object and not an array -- Add file_exists as allowed function -- Add in_array as allowed function ---- -Oct 8, 2017 -- Re-thinking the change in **June 10, 2013** about invalid JSON in assignments. Is important the dynamic path of JSON files: - -``` -{= i18n: i18n/{$lang}.json =} -``` - -`"i18n/{$lang}.json"` without quotes is invalid JSON - -Then, don't use quotes: -``` -{= i18n: "i18n/{$lang}.json" =} -``` - -- Important improvement for loading JSON data from relative path in template variable's assignment: - -``` - relative --> - | - v - /app/site/view/i18n/en/messages.json - ^ - | - replacement result -``` - -/app/site/view/page.tpl - -``` -{= lang: "en" =} -{= i18n: i18n/{$lang}/messages.json =} - -{$i18n.message1} -``` - -/app/site/view/i18n/en/messages.json -``` -{ - message1: "Hello" -} -``` - -Output: -``` -Hello -``` ---- -Oct 7, 2017 -- Change scope of `->loadTemplateProperties()` to public -- Other minor fixes -- Automatic update of template source code after `prepareDialect()` ... -- ... && new param for `->prepareDialect()` for disable automatic update ---- -Sep 30, 2017 [my birthday :)] -- Fix a bug with `getAuxiliaryEngine` (clone vs assignment) -- Add some new system vars - - `div.class_name`: the name of current invoked class ('div' or child of 'div') - - `div.super_class_name`: the name of super parent of current invoked class name (normally is 'div') -- Code review ---- -Sep 25, 2017 -- Fix and improve getAuxiliaryEngine ---- -Sep 9, 2017 -- Fix dynamic include's paths inside loops -``` -[$blocks] - {% blocks/block-{$id}.tpl %} -[/$blocks] -``` ---- -Jun 2, 2017 -- Improve the translator. Now you can translate from and to other dialects. - -```php -$tpl = new div("index.tpl", []); -``` - -Translate from other dialect to current dialect: - -```php -$tpl->translateFrom($dialectFrom); -``` - - Translate from current dialect to other dialect: - -```php -$tpl->translateTo($dialectFrom); -``` - -Translate from any dialect to any dialect: - -```php -$tpl->translate($dialectFrom, $dialectTo, $src, $items); -``` - -Maybe you need prepare the current dialect first: - -```php -prop = $tpl->getTemplateProperties(); -$tpl->__src = $tpl->prepareDialect(null, $prop); -``` ---- -May 29, 2017 -- Some bugfixs -- New variable for inline data of preprocessed templates: `div.standalone`, by default is FALSE. - This means that the "foo" variable will not be passed to the template pre-processor. That is, the variables in the parent template will be ignored and only the data specified in the line will be used. - -``` -{= foo: value =} -{%% block.tpl: { - div: { - standalone: true - } -} %%} -``` - - This better facilitates the recursive inclusion of templates, useful in generation of source code and other hierarchies like XML, HTML, JSON, etc. - -- Do not include anything within the conditional blocks if the conditions have not been resolved. This check prevent infinite loops. - -```php - ?$block - {%% block: {...} %%} <-- wait for block question results - $block? -``` - -- Priority change for items over filesystem when include o preprocess templates. To force load data from external file, please type the path or full path (ex: block.json) -``` -{= block: { - var1: "value1" - var2: "value2" -} =} -``` - - Take the block value - `{%% tpl: block %%}` - - Take json from external file - `{%% tpl: block.json %%}` - ---- -December 22, 2016 -- PHP 7 Compatibility check -- Release 4.9 version ---- -November 16, 2016 -- important bugfix/improvement: access to parent loop - -``` -[$parentloop] parent => - [$childloop] child => - Parent key: {$parent._key} - Child key: {$_key} or {$child._key} - [/$childloop] -[/$parentloop] -``` - -- TODO: test & release - -November 14, 2016 -- add new default subparser join - -Syntax: -``` -{join} varname | delimiter {/join} -``` - -index.tpl -``` -{= tags: ['a','b', 'c'] =} -{join} tags |, {/join} -{join} tags |,{/join} -{join} tags {/join} -``` - -Output: -``` -a, b, c -a,b,c -abc -``` ---- -October 10, 2016 -- Several tests -- Release 4.8 version ---- -January 12, 2016 -- review example ---- -December 24, 2015 -- improved dialect translator `div::translateFrom` -- some bug fixes -- update documentation ---- -December 23, 2015 -- add new feature for dialects: DIV_TAG_VAR_MEMBER_DELIMITER. This dialect's constant define a delimiter for variable's members. For example: - -by default you use: -``` -{$person.name} -``` - -but now you can do... - -index.php -```php -'); - - include "div.php"; - - echo new div("index.tpl", array( - 'person' => array( - 'name' => 'Peter', - 'child' => array( - 'name' => 'eli' - ) - ) - )); -``` -index.tpl -``` -{$person->child->name} -{$person->name} -``` - -TODO: improve dialect creator tool -TODO: check dialect translator method div::translateFrom() - - -December 19, 2015 -- several tests -- Release 4.7 version - -December 12, 2015 -- [starting release 4.7] -- some bug fixes, thanks to `gracix` and `Takefumi Ota` -- Improve template's vars and OOP: now you can access to a public method of any object. - -Example: - -index.php - -```php -first_name.' '.$this->last_name; - } - ... -} - -echo new div('index.tpl', array("person" => new Person(...))); -``` - -index.tpl - -``` -{= fullname: ->person.getFullName() =}` -The full name is {$fullname} -``` ---- -December 11, 2015 -- Bugfix in div class constructor -- Release 4.6 version ---- -December 1, 2014 -- some bug fixes -- Release 4.5 version ---- -November 24, 2014 -- improve `div::isValidPHPCode()` ---- -October 7, 2014 -- improve performance changing $vars with `__temp['vars']` var in `parseMacros();` because because `get_defined_vars` return also `vars` -- prevent infinite loops in `div::cop();` ---- -October 6, 2014 -- new setup var: `div.clear_locations` (= true by default). This means that the locations will be clear or not at the end (parse_level = 0). Then, the component are more flexible with **pre-processed templates**: - -comp.tpl - -```html -(( before )) (( after )) -``` - -index.tpl -```html -{%% comp: { - type: "text", - name: "first_name", - div: { - clear_locations: false - } -} %%} - - - -{{before before}} -{{after after}} -``` - ---- -September 26, 2014 -- bugfix `parseData()` vs `parseMatch()` logical order ---- -September 23, 2014 -- bug fix in `parsePreprocessed()` when $pdata is null -- bug fix with number formats inside loops ---- -September 21, 2014 -- new feature: advanced options/params for includes - -index.tpl -``` -{% subtpl: { - from: "", - to: "", - offset: 2, - limit: 1 -} %} -``` - -subtpl.tpl - -``` -Any text... - -Some text 1 - -Any text... - -Some text 2 - -Any text -``` - -- bugfix: Preparing allowed methods before execute the macros ---- -September 20, 2014 -- bugfix: Parsing macros inside preprocessed templates. New argument $min_level for parse() method. -- Add new allowed functions in macros, formulas and expressions: `array_keys` `get_object_vars` `is_object` -- new static method `div::div():` - -index.php - -```php - "value1")); -``` - -- Allow T_BREAK token in macros for foreach and other loops. Then, the follow macro is an error: -index.tpl - -```php - -``` - -Output -```shell -Fatal error: Cannot break/continue 1 level in div.php: eval()'d code on line 1 -``` ---- -September 17, 2014 -- bugfix/improve - Parsing orphan's parts while checksum not change. Do it because the orphans's parts stop the parser and the results are ugly. ---- -September 16, 2014 -- big fix: Set the priority to inline data in pre-processed templates above global design vars ---- -September 11, 2014 - -- bigfix: Save sections of loops and capsules when makeItAgain(); (Div doesn't know the future) - - -September 9, 2014 - -- bugfix: Adding items to array in templates - -{= somearray[]: "new item" =} - -- bugfix: Don't set item var as design var in div::parseData(); - - -September 8, 2014 - -- bugfix: Parse pre-processed templates with all items/vars (Div doesn't know the future) - - -August 28, 2014 - -- New feature for preprocessed templates: specific data - - Syntax: - - {%% tpl_file: data %%} - - data is: json, name of var or filename with json - - Example: - - Now is more simple for build the components: - - index.tpl - ------------ - {%% form: { - action: "login.php", - method: "post.php", - fields: [ - { - type: "text", - name: "user", - label: "User" - },{ - type: "password", - name: "pass", - label: "Password" - } - ], - submit: { - value: "login", - name: "btnLogin" - } - } %%} - - form.tpl - ------------ -
        - [$fields] - {$label}:
        -
        - [/$fields] - -
        - - -August 17, 2014 - -- Security fix: prevent obtrusive code in method calls. Now next code dont work: - -{= content: ->getPage(file_put_contents('some.txt','some text')) =} - - -August 5, 2014 - -- Fix the memory in the loops - - -August 4, 2014 - -- Fix macros parsing when a previous template var never match - - -August 2, 2014 - -- Allow is_array PHP function in macros -- New method for add literal vars in PHP: div::addLiteral(); - - -June 30, 2014 - -- Some bugfixs -- Add new important security feature: setup literals items/vars, for prevent injections! - -Example: - -index.tpl ---------------- -{= div.literals: ["text1", "text2"] =} - -{$text1} - -{$text2} - -{$text3} - -index.php ---------------- -echo new div('index.tpl', array( - 'text1' => '{/ignore}[:1,5:] {$value} [/]{ignore}', // I am being about deceiving the security - 'text2' => '[:1,100;] text to repeat [/]', - 'text3' => '[:1,3;] some [/]' -)); - -output ---------------- -[:1,5;] {$value} [/] -[:1,100;] text to repeat [/] -some some some - - -February 05, 2014 - -- Memory fixed! - - -December 25, 2013 - -- bugfix: div::fileExists and wrong include paths calculation - - -December 5, 2013 - -- Improvement of global design vars in loops and capsules - - -December 4, 2013 - -- bugfix: div::getFileContents() - - -August 30, 2013 - -- An important bug was fixed: the memory in the loops: - - In div 4.4 dont't work: - - index.php - ---- - array("Havana", "Tokyo"))); - - index.tpl - ---- - {= foo: [ - { title: "Cities", - content: '{% cities.tpl %}' - } - ] =} - - {% layout.tpl %} - - layout.tpl - ----- - ?$foo - [$foo] -

        {$title}

        - {$content}
        - [/$foo] - $foo? - - cities.tpl - ----- - ?$cities - [$cities] - {$value} - [/$cities] - @else@ - No cities - $cities? - - Output (wrong!) - ----- -

        Cities

        - No cities
        - - Output (great in 4.5) - ----- -

        Cities

        - Havana Tokio
        - - -July 29, 2013 - -- Decrease of priority in parser's specialchars - - -July 27, 2013 - -- bugfixs! -- Release 4.4 version - - -July 19, 2013 - -- bugfix the translator -- New feature: Multi template sources (based on include_path PHP setting) - -June 15, 2013 - -- Improvement of the modifier "escape single quotes" (\') - to "escape single/double quotes" (\"). -- Improvement of default documentation's template. - - -June 15, 2013 - -- Improvement of logs's system -- Release 4.3 version - - -June 13, 2013 - -- Integration with Google Chrome/Console and Mozilla Firefox/Firebug plugins. - Now the engine's messages will be appear in this browsers's features. - -- Improvement of detection of infinite loops in recursive replacements: - - index.tpl - ------------- - {= bar: {${$e}} =} - {= e: 'bar'} =} - - {$bar} - - Output - ------------- - [[ FATAL ERROR ]] WAS DETECTED AN INFINITE LOOP IN RECURSIVE REPLACEMENT OF $foo. - -- Improvement of parser and bugs fixes: if foo not existed, widget waits forever. - Now the next example works: - - index.tpl - ------------------ - {= widget: 45 =} - - {?( "{$foo}" == "a" )?} - {= bar: 5 =} - {/?} - - {$widget} - - Output - ------------------ - 45 - - Solved! - - -June 12, 2013 - -- Improvement of relative include/preprocessed templates. - Now the next example works: - - index.tpl - ------------------------- - {% folder/tpl1 %} - - /folder/tpl1.tpl - ------------------------- - {% folder2/tpl2 %} - - /folder1/folder2/tpl2.tpl - ------------------------- - {% tpl3 %} - - /folder1/folder2/tpl3.tpl - ------------------------- - Hello - - Ouput - ------------------------- - Hello - -- Improvement of template's variables assignment. - Now the next example works: - - index.tpl - ------------------------- - {= position: "absolute" =} - - {?( "{$position}" == "absolute" )?} - {= absolute: true =} - @else@ - {= absolute: false =} - {/?} - - ?$absolute YES $absolute? - - Ouput - ------------------------- - YES - -- Improvement of the variables's scope: - Now the next example works: - - index.tpl - ---------------- - {= foo: true =} - {= bar: [1,2,3] =} - - ?$foo - YES - $foo? - - [$bar] - {= foo: (# {$value} > 1 #) =} - ?$foo - YES - @else@ - NO - $foo? - [/$bar] - - {$foo} - - Output - -------------- - YES - - NO - - YES - - YES - - true - -June 10, 2013 - -- Improvement of the parser of template's vars: - If the value is not valid JSON, it will be considered as - a template and will be parsed before decoding. - - See the next sequence: - - 1. Value is not valid JSON: {= digits: [[:0,8:]{$value},[/]9] =} - 2. Value was parsed: {= digits: [0,1,2,3,4,5,6,7,8,9] =} - 3. Now "digits" is an array. - 4. Replacement: {$digits} - - See the difference: - - 1. Value is valid JSON: {= digits: "[[:0,8:]{$value},[/]9]" =} - 2. Value was not parsed: {= digits: "[[:0,8:]{$value},[/]9]" =} - 3. Now "digits" is an string. - 4. Replacement: {$digits} - -- Improvement of the parser of template's variables. Was improved - the detection of assignment of variables in any part of the - JSONs values. For example: - - index.tpl - --------- - - {= cities: ["New York", "Tokyo"] =} - - {= combobox: { - id: "cboCities", - options: $cities - } =} - - {$combobox.options.0} - - Output - --------- - New York - - -June 08, 2013 - -- Improvement of template's documentation -- Release new version 1.1 of Div Dialect Creator -- Release the version 4.2 - - -June 02, 2013 - -- Fix/improve the translator -- Fix/improve the parser - - -June 01, 2013 - -- Improvement of the parser of ignored parts -- Improvement of the parser of includes -- New feature: template's documentation. Now in the comments you can -document the template. The documentation's parts have @ as prefix. For example: - - - - To obtain the documentation data: - - $data = div::getDocs(); - - To obtain a readable documentation: - - echo div::getDocsReadable(/* optional template */); - -- Fix the algorithm of getRanges(). -- Fix the parser of macros. -- Added a new sub-parser's event: afterReplace. - -May 31, 2013 - -- Improvement of the algorithm of getRanges() to make all the possible one. Now -Div continues searching ranges after unclosed tags. - - - For next template: - - index.tpl - ---------- - {/ - {/div.now/} - - - In previous versions (1.0 - 4.1): - - Output: - ---------- - {/ - {/div.now/} - - - From Div 4.2: - - Output: - ---------- - {/ - 2013-05-31 - - -May 30, 2013 - -- Test new version -- Minor bugs was fixed -- Improvement of the detection of date formats -- Release 4.1 version - - -May 29, 2013 - -- Fix and improve the algorithm of div::getVarValue() method. -- Fix the detection of conditional parts. - - -May 27, 2013 - -- Change to private some div's properties -- Release 4.0 version - - -May 25, 2013 - -- Improvement of the conditional parts detection - - -May 24, 2013 - -- Fixed some bugs in locations and conditional parts. -- Created a translator of dialects. Now div have 2 new public methods: - - $tpl = new div('templateWithDialectX.tpl', $data); - - $dialectY = 'json code'; // or associative array - - // Return the translated template - $new_code = $tpl->translateFrom($dialectY); - - // Translate and change the original template - $tpl->translateAndChange($dialectY); - -- New feature: template properties. Now you can specify some properties -in the template's code, for example, the dialect of the current template: - - Example: - - index.tpl - -- - @_DIALECT = smarty.dialect - - {* this is a comment *} - Name: {$name} - - {literal} - {$name} - {/literal} - - {% other %} - - other.tpl - -- - @_DIALECT = twig.dialect - - {{ foo.bar }} - - smarty.dialect - -- - { - 'DIV_TAG_IGNORE_BEGIN': '{literal}', - 'DIV_TAG_IGNORE_END': '{/literal}', - 'DIV_TAG_COMMENT_BEGIN': '{*', - 'DIV_TAG_COMMENT_END': '*}' - } - - twig.dialect - --- - { - 'DIV_TAG_REPLACEMENT_SUFFIX': ' }}', - 'DIV_TAG_MODIFIER_SIMPLE': '{ ' - } - - index.php - --- - 'Peter', - 'foo' => array( - 'bar' => 45 - ) - )); - - Output - --- - Name: Peter - - {$name} - - 45 -- New feature: predefined subparsers. Div provide pre-defined sub-parsers, for example, - {parse}...{/parse}. This example of sub-parser make a pre-proccess of enclosed code. - This means that a new instance of div will be created, similar to the loops - and the capsules. Other predefined subparsers will be developed in future releases. - -- New feature: sub-parser's events. Now in the templates's code you can specify when - a sub-parser will be executed: beforeParse, afterInclude or afterParse. Example: - - index.tpl - --------------------------- - {= name: "Peter" =} - {= products: [ - { - name: "banana", - price: 40 - }, - { - name: "potato", - price: 25 - } - ] =} - - [$products] - {parse:beforeParse} - Name: {$name} - {/parse:beforeParse} - - Product name: {$name} - - {% other %} - [/$products] - - other.tpl - --------------------------- - {parse:beforeParse} - Other name: {$name} - {/parse:beforeParse} - - Output - ---------- - Name: Peter - Product name: banana - Other name: banana - Name: Peter - Product name: potato - Other name: potato - - -May 18, 2013 - -- Created a tool to build dialects. -- Release the 3.9 version - - -May 10, 2013 - -- Enable custom dialect for developers! - - A dialect is defined by the group of constant whose name - begins with DIV_TAG. This dialect is subject to some simple - rules that Div forces to complete for preveer inconsistencies and - infinite loops. - -- New static method isValidCurrentDialect, for detect error in the - definition of current dialect, based on this rule: - - some tags are required, like as, prefixes, suffixes, beginnings and ends. - - some tags must be unique, like as, modifiers, else, break, empty, ... - - -May 9, 2013 - -- New static method anyToStr, for convert mixed value to string based on this rule: - - string is string - - boolean is "true" or "false" - - number is "number" - - object with __toString() is __toString() - - object without __toString() is array - - array is count() -- Changed the type of unchangeable methods to "final". - - -May 3, 2013 - -- The interpretation of date format was improved. - - If you need type the char ":" in the format, and this - char is the separator between var and format, then type - a backslash before ":", like as this: - - {/2012-01-01 00:30:00 : Y-m-d h\:i\:s/} - - In the example the value is "2012-01-01 00:30:00 " and - the format is "Y-m-d h:i:s". - - -April 29, 2013 - - -- The interpretation of aggregate functions was improved. - The next example work now: - - index.tpl - ------------ - {= products: [ - {name: "Banana", price: 10}, - {name: "Potato", price: 20} - ] =} - - {$products.0.price} - {#products.0.price:2#} - - {$sum:products-price} - {#sum:products-price:2,#} - {%sum:products-price} - - Output - ------------- - 10 - 10.00 - - 30 - 30,00 - 2 - - -April 24, 2013 - -- Performance: work remembered! Now the engine can remember some - actions from previous work and increase their speed. -- New feature: the macros. - - A macro is a restricted PHP code inside the templates to facilitate the complex processing - with the advantages of this language. The security is guaranteed. See the next silly example: - - index.php - ---------- - 'Hello world')); - - index.tpl - ------------- - - - {$title} - - Output - ----------- - Hello world - - HELLO WORLD - -- New feature: the custom sub-parsers - - A sub-parser is a parser implmemented by the programmer. For example: - - index.php - -------------- - 'Hello world')); - - index.tpl - ---------------- - - {literal} - - {/literal} - - {$title} - - Ouput - ---------------- - - - Hello world - - -April 17, 2013 - -- bugfix in the bodies of multi-replacements -- Changed the name of method multiReplace by parseMultiReplace - - -April 13, 2013 - -- The template variables's manipulation was improved: - - Example: - --------------- - - {= product: { - name: "banana" - price: 20 - } =} - - Name: {^product.name} - Price: ${#product.price:2.#} - - {= product.price: (# {$product.price} * 2 #) =} - - Double price: ${#product.price:2.#} - - [[product - Current price: {$price} - product]] - - Output: - ---------------- - - Name: banana - Price: $20.00 - - Double price: $40.00 - - Current price: 40 - -- New static methods are added: - - div::issetVar($var, $items) - div::unsetVar($var, $items) - div::setVarValue($var, $value, $items) - div::getVarValue($var, $items) - div::getVars($items) - - Example: - --------------- - product - [1] => product.name - [2] => product.price - ) - -- The method setItem and getItem was improved with detection of complex variable's names: - - Example: - ---------------------- - - array( - "name" => "Banana", - "price" => null - ) - )); - - $tpl->setItem("product.price", 10); - - index.tpl - ------------------- - Name: {$product.name} - Price: ${#product.price:2.#} - - Output - ------------------ - Name: Banana - Price: $10.00 - -April 12, 2013 - -- The order respect of template variables's manipulation was improved: - - Example: - ------------- - {= a: 5 =} - - {$a} - - {= a: (# {$a} + 1 #) =} - - {$a} - - {= a: (# {$a} + 1 #) =} - - {$a} - - Output: - ----------- - - 5 - - 6 - - 7 - -April 11, 2013 - -- bugfix of template variables when it use object's methods - Now you can call a object's method with some ways: - - Similar to PHP: - - {= result: ->method(param1, param2, param3) =} - - One parameter as JSON data: - - {= result: ->method({param1: value1, param2: value2}); - -- bugfix of loops, prevent a recursion with var '_item' as object inside the same object: - - Product Object - ( - [price] => 0 - [quantity] => 0 - [_item] => Product Object - *RECURSION* - ) - - -April 07, 2013 - -- Fix some issues -- New method div::isSring as a safe is_string(): - - if is a string return true - - if is a object with __toString method return true - - -April 04, 2013 - -- The scalar values as a complex values! What? - - Yes! Now all the scalar values can be used as strings. Then, the strings can be - used like complex values, that is to say, as group of characters. For example: - - index.tpl - -------------- - {= name: "Peter" =} - - - {$name.0} - - - {$name.1} - - {= x: 537 =} - - - {$x.0} - - - {$x.1} - - - [$name]{$value} [/$name] - - - [$x] {$value} * [/$x] = (# [$x] {$value} * [/$x] 1 #) - - Output: - ---------------- - P - - e - - 5 - - 3 - - P e t e r - - 5 * 3 * 7 = 105 - - -April 03, 2013 - -- Version 3.7 was released with a serious error that was corrected in the 3.8 - -- Release the 3.8 version - - -March 30, 2013 - -- Improved the interpretation of third parameter of the constructor - as a string with the variables's names. - - echo new div('index.tpl', array('name' => 'Peter', 'age' => 25, 'sex' => 'M'), 'name,age'); - -- Release the 3.7 version - - -March 26, 2013 - -- Improvement of the speed. -- Improvement of the options arround the __toString method of objects in 3 scopes. See the example below. - - The old policy: - - "if an object has implemented the method __toString then be treated as a string" - - It was changed for: - - "if an object has implemented the method __toString, you can work with the object as a character string" - - - Example: - - index.php - --------- - name = $name; - $this->price = $price; - } - - public function __toString(){ - return $this->name.' ($'.$this->price.')'; - } - } - - // The object as string - echo new div('index.tpl', array("product" => new Product('Banana', 10))); - - // Template scope - echo new div('index1.tpl', array(new Product('Banana', 10))); - - // Capsule scope - echo new div('index2.tpl', array("product" => new Product('Banana', 10))); - - // Loop's body scope - echo new div('index3.tpl', array("products" => array(new Product('Banana', 10)))); - - ?> - - index.tpl - ------------ - {$product} - - Output for index.tpl - -------------------- - Banana ($10) - - index1.tpl - ---------- - {$value} - - is similar to - - {$_to_string} - - index2.tpl - ---------- - [[product - - {$value} - - is similar to - - {$_to_string} - - product]] - - index3.tpl - ---------- - [$products] - {$value} - - is similar to - - {$_to_string} - [/$products] - - Same output for index1, index2 and index3 - ------------- - Banana ($10) - - is similar to - - Banana ($10) - -March 24, 2013 - -- From version 3.6 Div maintains a policy regarding the use of objects: if an -object has implemented the method __ toString then be treated as a character string. -We are working to improve the policy and avoid unhappy. - - index.php - - name = $name; - $this->price = $price; - } - - public function __toString(){ - return $this->name.' ($'.$this->price.')'; - } - } - - echo new div('index.tpl', array("products" => array(new Product('Banana', 10)))); - ?> - - index.tpl - - [$products] - {$value} - [/$products] - - Output - Banana ($10) - - We are working to improve the policy and avoid unhappy. - -March 22, 2013 - -- Some functions of PHP are enabled in formulas and conditions. - -- Added a new system var named: $div.ascii. This var contain the all chars of ASCII table. - - - - index.tpl - ----------- - {$div.ascii.64} - - is similar to - - (# chr(64) #) - - but the replacement is faster than calculation - - Output: - ------- - @ - - is similar to - - @ - - but the replacement is faster than calculation - - -March 20, 2013 - -- Added a new feature for programmers: the method changeTemplate() - - "Hello world")); - - echo $tpl; // $tpl->show(); - - $tpl->changeTemplate('index2.tpl'); - - echo $tpl; // $tpl->show(); - - ?> - -- Improvement of the show() method with a new parameter: specific template - - title = "Hello world"; - $tpl->show('template.tpl'); - - ?> - -March 18, 2013 - -- Added new variable's modifiers: - - {&&var} - rawurlencode - {'var} - escape unescaped single quotes - {js:var} - escape quotes and backslashes, newlines, etc. - {$var:[string format]} - format the value with sprintf PHP function - -- Added new feature for programmers: custom variable's modifier - - For add a new custom variable's modifier you need call the method: - - div::addCustomModifier($prefix, $function) - - The parameter $function can be the name of function or the name of static method of a class, for example - - div::addCustomModifier('upper', 'MyModifiers::upper'); - - Example: - ---------------- - index.php - - 'http://localhost')); - - ?> - - index.tpl - ----------- - - {upi:url} - - - Output - ----------- - http%3A//localhost - -- Added new feature for programmers: the hooks!. The hooks are: - - beforeBuild, afterBuild, beforeParse, afterParse - - Example: - - index.php - --------------- - class HomePage extends div{ - - public function beforeBuild(){ - $this->__src = "index"; - $this->setItem(array( - "title" => "Hello World" - )); - } - } - - echo new HomePage(); - - index.tpl - --------------- -

        {$title}

        - - Output - ---------------- -

        Hello World

        - -- Improvement of the setItem method - - -March 16, 2013 - - -- Improved the access to object's public methods - - index.php - ------------------- - first_name = $first_name; - $this->last_name = $last_name; - } - function getCompleteName(){ - return $this->first_name.' '.$this->last_name; - } - } - - echo new div('index.tpl', array( - 'person' => new Person('John', 'Nash') - )); - - index.tpl - --------------------- - [[person - - {= cn: ->getCompleteName() =} - - First Name: {$first_name} - Last Name: {$last_name} - Complete name: {$cn} - - person]] - - Output - ---------------------- - First Name: John - Last Name: Nash - Complete name: John Nash - -- Release the 3.6 version - - -March 13, 2013 - -- Improved the feature "template vars". Now you can execute the "methods of information". - - Example: - - index.php - ---------------- - - - index.tpl - ------------------ - - somedata is: {$somedata} - - {= names: ->getNames() =} - - The names are: [$names] {$value} [/$names] - - - Output - -------------------- - somedata is: 100 - - The names are: Jones Pete Mark - - -March 13, 2013 - -- Improved the detection of orphan conditional parts - - -March 8, 2013 - -- Update the documentation -- Fixes some bugs of new features -- Release the 3.5 version - - -February 24, 2013 - -- New feature: locations! - - Now you can define a diferent locations in your template - and put in this locations any content. - - - Example: - ----------------- - (( top )) - - (( any )) Some content here (( any )) - - (( bottom )) - - {{top - This is the top of the page - top}} - - {{bottom - This is the bottom of the page - bottom}} - - {{any -
        - any}} - - Output: - ----------------- - This is the top of the page - -
        Some content here
        - - This is the bottom of the page - -- Improvement of the conditional parts: the first and last blank space are removed. - - In Div 1.0 to 3.4: - --------------------- - - ?$what Hello $what? - - Output: - --------------------- - Hello - - From Div 3.5: - --------------------- - - ?$what Hello $what? - - Output: - --------------------- - Hello - - -February 24, 2013 - -- New feature: @empty@ tag for list's blocks - - [$users] - {$name} - @empty@ - Show this if list users is empty - [/$users] - - -February 19, 2013 - -- The documentation was updated -- Improved detection of infinite loops on includes and replacements -- Release the 3.4 version - - -February 17, 2013 - -- Add new feature: Multiple variable's modifiers - - Syntax: - ---------- - {$varname|modifier1|modifier2|modifier3|...|} - - index.tpl - ---------- - {= word: "ABCDEFG" =} - - {$word|0,3|} - {$word|0,3|_|} - {$word|0,3|_|^|} - {$word|0,3|_|^|~2|} - - Output - ------- - ABC - abc - Abc - Ab - - -February 15, 2013 - -- Fix a critical bug: prevented infinite cycle -- Release the 3.3 version - - -February 4, 2013 - -- Fix a bug with {ignore} functionality -- Add new vars for the iterations: $_previous and $_next. - - index.tpl - ------- - {= list: [10,5,7,12,8,8,10,10] =} - [$list] - {= _previous: 0 =} - {= _next: infinite =} - {$_previous}..{$value}..{$_next} - [/$list] - - Output - ------ - 0..1..2 - 1..2..3 - 2..3..4 - 3..4..5 - 4..5..6 - 5..6..7 - 6..7..8 - 7..8..9 - 8..9..10 - 9..10..infinite - -- Algorithm improved: 95% more faster. -- Release the 3.2 version - - -Dec 26, 2012 - -- Improved date's values detection - - -Nov 21, 2012 - -- Update documentation -- Release 3.1 version - - -Nov 21, 2012 - -- Detection of recursive inclusion as an error. For example: - - index.tpl - ------------- - - {% index %} - - -Nov 19, 2012 - -- Improved the algorithm of lists/loops/cycles - - -Nov 16, 2012 - -- Allowed "intval" PHP function in formulas - - -Nov 4, 2012 - -- Fix some problems -- Improvement of some mechanisms -- Release the 3.0 version - - -Sep 7, 2012 - -- Fix important issue for matchs. Now work the follow example: - - {= list: [ - { - name: "Banana", - price: 20, - shipments: [ - { - date: "2012-05-09", - packages: [ - [20, 30, 40] - ] - } - ] - }, - { - name: "Potato", - price: 40 - } - ] =} - - {$list}
        - {$list.0}
        - {$list.0.shipments}
        - {$list.0.shipments.0}
        - {$list.0.shipments.0.adresses}
        - {$list.0.shipments.0.adresses.0}
        - {$list.0.shipments.0.adresses.0.0}
        - - -Sep 2, 2012 - -- Fix bugs of conditions into loops - -Sep 2, 2012 - -- Fix bugs -- Release the 2.9 version - -Aug 30, 2012 - -- Improvements to the template's vars. Now you can do this: - - article.tpl - ----------------- - -

        {$title}

        -

        {$body}

        - - - page.tpl - ------------------ - {= content: article =} - - Header - - {$content} - - Footer - - -Aug 20, 2012 - -- Delete the DIV_CLASS_NAME constant: now is more simple to change the name of - div class. Simply change the name of div class, no more! - -- Fix problem of template vars's scope. The inheritance mechanism is more simple now: - - ------------------- - parent.tpl - ------------------- - - {= block1: - - ...some code here... - - =} - - - {$block1} - - ------------------- - child.tpl - ------------------- - - {= *block1: - - ...some another code here... - - =} - - - {% parent %} - - -Aug 18, 2012 - -- The algorithm of text summary was improved. -- New feature: IDE's friendly marks - - Example: - - - -

        Name: {$name}

        -

        Price: {$price}

        - - - Expensive product - - - - - Is similar to: - - [$products] - -

        Name: {$name}

        -

        Price: {$price}

        - - {?( {$price} > 10 )?} - Expensive product - {/?} - - [/$products] - - -Aug 17, 2012 - -- Change the type of method of getSystemData from public to static - -Aug 16, 2012 - -- Change the type of method of mixedBool from public to static. -- Release the 2.8 version - - -Aug 09, 2012 - -- Added new feature: Relative paths for include and preprocessed templates. - - -Aug 07, 2012 - -- Freed of the function json_encode of PHP and corrected some errors of this function. - - -Aug 05, 2012 - -- Fixed bugs: - - If you don't define a variable, the expression is FALSE: - - Example: - "some")); // var2 is missing - - index.tpl - ---------- - - {?( "{$var1}" == "some" && "{$var2}" == "another" )?) - Part 1 - @else@ - Part 2 - {/?} - - Output: - ---------- - Part 2 - - - If you don't define a variable, the formula will be ignored: - - Example: - 2)); // var2 is missing - - index.tpl - ---------- - - (# {$var1} + {$var2} #) - - Output: - ---------- - - (# 2 + {$var2} #) - - -Aug 03, 2012 - -- Fixed bugs -- Release the 2.7 version - - -Jul 30, 2012 - -- Fixed bugs -- Add new feature for json encode. - - Example: - - array(1,2,3,4,5))); - - {json:variable} - - Outoput: - - [1,2,3,4,5] - - -Jul 26, 2012 - -- Fixed bugs -- Release the 2.6 version - - -Jul 08, 2012 - -- Added new features for replacements: multiple replacements - - - - {= replac: [ - ['search this string', 'replace with this string', false], - ] =] - - - - {:replac} - - ... some code here .... - - {:/replac} - - - Example: - ---------- - - {= php-code: [ - ['echo ', 'echo '], - ['/\'([^\'](?:\\.|[^\\\']*)*)\'/i', '\'$1\'',true] - ] =} - - {:php-code} - - - - {:/php-code} - - Output: - ---------- - - echo 'hello world' - ?> -- Fixed bugs - - -Jul 02, 2012 - -- Add new features for performance: enable and disable system var - - div::enableSystemVar("div.session"); - div::disableSystemVar("div.server"); - ... - - -Jun 30, 2012 - -- Fixed bugs -- Added new funcionality for log: Save the steps of the parser into log file - - // Save the steps of the parser into log file - div::logOn("mylogfile.log"); - ... -- Release the 2.5 version - - -Jun 13, 2012 - -- Fixed bugs -- Added new functionality: html to text - - {txt} ... some html code here .. {/txt} - {txt} width => ... some html code here {/txt} - - The width integer parameter, wrap the text with this width. - - -Jun 8, 2012 - -- Fixed bugs -- Added new functionality: text wrap - - If you needed the wrap of a text with a specific width, you can do this: - - {$body:/200} - - If you use the br modifier, the text wrap take effect on the web: - - {br:body:/200} -- Release the 2.4 version - - -May 27, 2012 - -- Added new functionality: show the teaser of a text. Similar to get a substring of text: - - {$mytext:100} - - If you add the symbol ~, you can retrieve the teaser of $mytext: - - {$mytext:~100} - -May 22, 2012 - -- NEW: Allow to asign a program var to a template var. For example: - - index.php - ------------- - 5)); - ... - ?> - - index.tpl - ------------- - - {= another: $some =} - - {$another} - - Output - ------------- - 5 - - Also you can asign to the specific property of template var: - - index.tpl - -------------- - {= someobj: { - property: "$some" - } =} - - {$someobj.property} - -- Release the 2.3 version - - -May 19, 2012 - -- NEW: Allowed functions. Now the programmer can enable functions - of or written in PHP so that the designer can use them in the templates. - - - - index.tpl - ----------------- - (# sum(2,3) #) - -- NEW: Add new item to list or set a property of object: - - TEMPLATE - ------------- - ... some more code here ... - - {= list: [1,2,3] =} - {= customer: { - name: "Peter", - phone: "222-444555" - } =} - - ... some more code here ... - - {= list[]: 4 =} - {= customer[address]: #221 street 45 =} - - ... some more code here ... - - {$list.4} - - {$customer.address} - - -May 14, 2012 - -- Fixed bugs -- Release 2.2 version - - -May 13, 2012 - -- New functionality: assign to design vars the result of method! If the programmer - implemented a class that inherits of div, then the designer can use the methods of this - class. - - Syntax for template: - - {= variable: ->methodName(params as JSON) =} - - For example: - - Page.php - -------------------------- - x + $params->y; - } - - public function getLetters(){ - return array("A","B","C"); - } - - } - ?> - - Page.tpl - --------------------------- - - {= sum: ->getSum(x: 20, y: 30) =} - - {$sum} - - {= lts: ->getLetters() =} - - [$lts] {$value} [/$lts] - - Output - --------------------------- - 50 A B C - -May 12, 2012 - - -- Now the definition of data in templates is similar to set a global var in the programmer side - and you can re-refine this data every time in the template and now the sequence of the operations - is not ignored. The variables have arrived! - - For example: - - -- - TEMPALTE - -- - - - - {= products: [ - {price: 10, qty: 5}, - {price: 20, qty: 2} - ] =} - - {= invoice_price: 0 =} - {= tax: 20 =} - - [$products] {= invoice_price: (# {$invoice_price} +{$qty} * {$price} #) =} [/$products] - - Invoice price: {#invoice_price:2.#}
        - - Tax: {#tax:2.#}
        - - - - {= invoice_price: (# {$invoice_price} + {$tax} #) =} - - Total price: {#invoice_price:2.#} - - -- - OUTPUT - -- - Invoice price: 90.00 - Tax: 20.00 - Total price: 110.00 - - -- Fixed bugs - -- Add new functionality: capsules!, with the symbol of Div logo!.... of course! - - Now you can create capsules inside the insole to reduce the code and to facilitate - the work with objects and arrangements. A capsule consists on a block that fulfills - the following syntax: - - [[variable - - ... In this section you can use the properties of variable if it is - an object or their keys if it is an array ... - - variable]] - - For example: - - index.php - ------------------- - - array( - "name" => "Banana", - "price" => 20.4 - ) - )); - ... - ?> - - index.tpl - --------------------- - - [[product - Name: {$name}
        - Price: {$price}
        - product]] - - Enjoy! - -- Add new feature for iterations functionality: now you can specify a STEP for iteration. - - Syntax: - ------------------ - - Variant 1: - - [:from,to,var,step:] - - Variant 2: - - [:from,to,step:] - - Example 1: - ---------------- - - Template: - - [:1,10,2:] {$value} [/] - - Output: - - 1 3 5 7 9 - - Example 2: - ----------------- - - [:1,10,i,2:] {$i} [/] - - Output: - - 1 3 5 7 9 - - Example 3: - ----------------- - [:10,1,i,2:] {$i} [/] - - 10 8 6 4 2 - -- Another way to define the iteration var with high priority. Now the follow templates are similars: - - Template 1: - - [:1,10,x:] .... [/] - - Template 2: - - [:1,10:] x => .... [/] - - The follow example shows the priority of this new way: - - Template: - - [:1,10,x:] y => {$y} {$x} [/] - - Output: - - 1 {$x} 2 {$x} 3 {$x} 4 {$x} 5 {$x} 6 {$x} 7 {$x} 8 {$x} 9 {$x} 10 {$x} - - -May 09, 2012 - -- Added aggregate functions for the lists: sum, avg, min, max, and the default count function - - Now the designer can calculate another statistics from lists, for example: - - index.php - -------- - array( - array("name" => "Banana", "price" => 20.5), - .... - ... - ... - ), - "values" => array(10,20,30,40,50,60) - )); - - ... - ?> - -------- - - index.tpl - -------- - Minimum price: {$min:products-price} - Maximum price: {$max:products-price} - Average of prices: {$avg:products-price} - Sum of prices: {$sum:products-price} - Count of products with price: {$count:products-price} or {$products-price} - - - - Minimum value: {$min:values} - Maximum value: {$max:values} - Average of values: {$avg:values} - Sum of values: {$sum:values} - -------- - -- Added a new constant constant DIV_CLASS_NAME for define the name of de superclass of div. - Now the programmer can change the name of the div class to avoid possible - collisions the class's names of his application. - -- Added a new functionality: default replacements by variable. - - Now the programmer and the designer can define the default replacements for values - by variable. For example: - - Set the default replacement in PHP: - - true)); - ?> - - - Or set the default replacement in the template: - - ... - {@["kept", true, "YES"]@} - {@["kept", false, "NO"]@} - ... - - -May 08, 2012 - -- Added a new functionality: pre-processed parts. - - Now you can pre-processed by div any part in template. The pre-processing - are similar to include, but the pre-processing parse the code before including it. - - Include is: {% part.tpl %} (include and then parse) - Pre-processing is {%% part.tpl %%} (parse and then include) - - IMPORTANT!: The pre-processing have a priority with regard to the list interations. - -- Release the 2.1 version - - -May 06, 2012 - - -- Enable two new properties for PHP developers: $__src and $__packages. - See the follow example: - - - -- If you want that the names of the files have a prefix, specify it in constant - PACKAGES or in the property $__packages of a class that extends the div. See - the following examples: - - Example 1 - ---------------- - - - Example 2 - ---------------- - - -- Add new constant DIV_DEFAULT_TPL_FILE_EXT for define a template file extension. - You can define this constant BEFORE include the div.php script. The default value - for this constant is the string "tpl". For example: - - - -- Add new constant DIV_DEFAULT_DATA_FILE_EXT for define a data file extension. - You can define this constant BEFORE include the div.php script. The default value - for this constant is the string "json". For example: - - - -- Implement the show() method. - - show(); - - ?> - -- If you don't pass the value of $src for the div class constructor, then - Div assumes that $src is the name of the class :) - - - -- Enable the div extends for OOP in the programmer side. The name of the properties - should not begin with __ (double underscore). See the follow example: - - Page.tpl - ------------- -

        {$title}{$body}

        - - Page.php - ------------- - - - index.php - ------------- - title = "Hello world"; - $page->body = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.."; - $page->show(); // or echo $page; - - ?> - - -April 21, 2012 - -- Change mixedBool() and parseMatch() methods for trim the string values. - - -April 14, 2012 - - -- Added a new variable for the cycles: $_order, that is $_index + 1. - The index begins with 0. The order bigins with 1. This is util when you - need build a ordered list without
          tag and reused item template. - - For example: - - The ordered list: - --- - - [$list] - {% reused %} - [/$list] - - The reused template reused.tpl: - --- - - ?$_order {$_order}. $_order? Name: {$name} Address: {$address} - - On the other hand if you use the following template for reuse.tpl, - the first order number will be hidden and the template is more complicated: - - ?$_index (# {$_index} + #). $_index? Name: {$name} Address: {$address} - -- Added new variable's modifiers: html and br - - {html:variable} convert all applicable chracters to HTML entities (see the - documentation of htmlentities() PHP function) - - {br:variable} convert all \n to
          - -- Fixed bugs of recursivity and recovered the high priority of variables into the cycles. - -- Release the 2.0 Version - - -April 09, 2012 - - -- Fix some grave bugs of iterations functionality and other improvements. - -- Added a new functionalitites: - - Custom item variable for lists and mark =>. For example: - - {= clients: [ - { - name: 'John', - products: [{name: 'Banana', price: 1.2},{name: 'Potato', price: 1.3}] - } - ] - =} - - [$clients] client => - [$products] - {$client.name} - {$name}
          - [/$products] - [/$clients] - - - - Custom item variable for iterations: you now can specify the iteration variable. For example: - - [:1,100,i:] - The current value is {$i} - [/] - - - Nested iterations. The following example... - - [:1,10,i:] - [:1,10,j:] - {$i} * {$j} = (# {$i} * {$j} #)
          - [/] - [/] - - ...is similar to: - - "; - - ?> - - - New variable for iterations and lists's cycle - - - $_list, that it contains the list's name. - - For example: - - [$products] - {$_list} - [/$products] - - Div associates a name to each iteration that you define. With this new functionality - you can know the name of the iteration inside the cycle of the iteration. - - Also, if you use the recursion, you can work now with the name of the list thanks to - this new variable that doesn't collapse with a variable inside the cycle. - - For example: - - {= list: "products", - products: [ - count: 3, - list: ["Banana", "Potato" , "Rice"] - ] - =} - - [{$list}] - {$_list} <--{ This shows the same thing that {$list} that is 'products' ... }--> - {$list} <--{ This shows the count of items of [$list] }--> - [$list] <--{ and this list is a list into the parent cycle }--> - {$value}, <--{ This shows Banana, Potato, Rice }--> - [/$list] - [/{$list}] - - - $_item, that it contains the list's item - - For example: - - {= products: [ - { - name: "Banana", - price: 1.2 - }, - { - name: "Potato", - price: 1.3 - } - ] =} - - [$products] - {$_item} - {$_item.price} is similar to {$price} - [/$products] - - - $_key, that it contains the item's key - - For example: - - [$products] - [$_item] - {$_key}: {$value} - [/$_item] - [/$products] - -- Release the 1.9 version - - -April 07, 2012 - -- Recovering a lost functionality. In version 1.5 to make the algorithms more efficient -we made a mistake and break functionality of the clean the orphan parts. Now in version 1.8 -is working again just as quickly. - -- Fix some grave bugs. - -- Added new funtionalities: - - If a var contain an object, {$var} will be repleace with the count of properties - - Sub matches: now you can write ($var:0,20} or {$var:20} to replace this mark with - substr($var, 0, 20); - - With this new functionality you can chop a text in half thank - to the formulas, for example: - - {$text: (# {%text} / 2 #)} - {$text: (# {%text} / 2 #), (# {%text} / 2 #)} - - You can also make use of the variable's modifiers: - - {^text: 1} - -- Release the 1.8 version. - -Note: The new added features made a little slower the engine. We are working -in the improvement of the algorithms. - -April 05, 2012 - -- Recovering a lost functionality. In version 1.5 to improve the algorithms made a - mistake and break functionality of the Formulas. Now in version 1.7 is working again - just as quickly. - -- Added new functionality for programmers in the constructor of div class with - new parameter: IGNORE SOME VARIABLES. Example: - -// ignoring the "name" variable -echo new div("index.tpl", array("name" => "Salvi", "age" => 25), array("name")); - -- Prevent a bugs with length two first parameters as filenames, in the div constructor -- Release the 1.7 version - -April 2, 2012 - -- In version 1.5 to improve the algorithms made a mistake and lost functionality - of the iterations of Lists, which is the priority of an item variable under way, - with the same name of a variable outside the loop. Now in version 1.6 is working - again just as quickly. - -- Release the 1.6 version - -March 30, 2012 - -- The algorithm was improved. Div is faster now. -- Fixed bugs. -- A new variable's modifier was added to encode URL. For example: - - {&variable} - -- Release the 1.5 version - -March 28, 2012 - - -- Fixed bugs of blocks of conditions -- Add new feature named ITERATIONS. - - Example: - - [:1,5:] {$value} [/] - - Output: - - 1 2 3 4 5 -- Release the 1.4 version - -March 23, 2012 - -- Prevent the errors of formulas -- Prevent the errors of conditions -- Fix important bug of @else@ mark of conditions into other conditions and conditionals -- Release the 1.3 version - -March 22, 2012 - -- The @break@ mark - Add break mark for breaking the loops. The position of - break mark in the block are relevant! - - Example: - - [$products] - {?( {$_index} == 3 )?}
          @break@ {/?} - {$value}
          - [/$products] - -- Release the 1.2 version - -March 15, 2012 - -- Fixing some several issues of conditional parts! - -- Release the 1.1 version \ No newline at end of file diff --git a/releases/v1.1.0.md b/releases/v1.1.0.md index be0c057..83612dc 100644 --- a/releases/v1.1.0.md +++ b/releases/v1.1.0.md @@ -1,11 +1,15 @@ # Release v1.1.0 + Date: 2012-03-15 ## Description +March 15, 2012 + - Fixing some several issues of conditional parts! - Release the 1.1 version ## Commits + - No commits found. diff --git a/releases/v1.2.0.md b/releases/v1.2.0.md index b315f3a..1ea0b2f 100644 --- a/releases/v1.2.0.md +++ b/releases/v1.2.0.md @@ -1,20 +1,25 @@ # Release v1.2.0 + Date: 2012-03-22 ## Description -- The @break@ mark - Add break mark for breaking the loops. The position of - break mark in the block are relevant! +March 22, 2012 + +- The @break@ mark Add break mark for breaking the loops. The position of break mark in the block are relevant! - Example: +Example: - [$products] - {?( {$_index} == 3 )?}
          @break@ {/?} - {$value}
          - [/$products] +```html +[$products] +{?( {$_index} == 3 )?}
          @break@ {/?} +{$value}
          +[/$products] + +``` - Release the 1.2 version ## Commits + - No commits found. diff --git a/releases/v1.3.0.md b/releases/v1.3.0.md index e95d859..d636062 100644 --- a/releases/v1.3.0.md +++ b/releases/v1.3.0.md @@ -1,12 +1,16 @@ # Release v1.3.0 + Date: 2012-03-23 ## Description +March 23, 2012 + - Prevent the errors of formulas - Prevent the errors of conditions - Fix important bug of @else@ mark of conditions into other conditions and conditionals - Release the 1.3 version ## Commits + - No commits found. diff --git a/releases/v1.4.0.md b/releases/v1.4.0.md index 2c44442..9437e53 100644 --- a/releases/v1.4.0.md +++ b/releases/v1.4.0.md @@ -1,20 +1,29 @@ # Release v1.4.0 + Date: 2012-03-28 ## Description +March 28, 2012 - Fixed bugs of blocks of conditions - Add new feature named ITERATIONS. - Example: +Example: + +```div +[:1,5:] {$value} [/] - [:1,5:] {$value} [/] +``` - Output: +Output: + +```div +1 2 3 4 5 +``` - 1 2 3 4 5 - Release the 1.4 version ## Commits + - No commits found. diff --git a/releases/v1.5.0.md b/releases/v1.5.0.md index c6796bd..21f1f94 100644 --- a/releases/v1.5.0.md +++ b/releases/v1.5.0.md @@ -1,15 +1,22 @@ # Release v1.5.0 + Date: 2012-03-30 ## Description +March 30, 2012 + - The algorithm was improved. Div is faster now. - Fixed bugs. - A new variable's modifier was added to encode URL. For example: - {&variable} +```div +{&variable} + +``` - Release the 1.5 version ## Commits + - No commits found. diff --git a/releases/v1.6.0.md b/releases/v1.6.0.md index 3bd4bae..d60fc3e 100644 --- a/releases/v1.6.0.md +++ b/releases/v1.6.0.md @@ -1,14 +1,15 @@ # Release v1.6.0 + Date: 2012-04-02 ## Description -- In version 1.5 to improve the algorithms made a mistake and lost functionality - of the iterations of Lists, which is the priority of an item variable under way, - with the same name of a variable outside the loop. Now in version 1.6 is working - again just as quickly. +April 2, 2012 + +- In version 1.5, to improve the algorithms, a mistake removed the iteration feature for Lists (the priority of an item variable under way with the same name as a variable outside the loop). Now in version 1.6 it works again just as quickly. - Release the 1.6 version ## Commits + - No commits found. diff --git a/releases/v1.7.0.md b/releases/v1.7.0.md index 8d7010a..eef748b 100644 --- a/releases/v1.7.0.md +++ b/releases/v1.7.0.md @@ -1,20 +1,26 @@ # Release v1.7.0 + Date: 2012-04-05 ## Description -- Recovering a lost functionality. In version 1.5 to improve the algorithms made a - mistake and break functionality of the Formulas. Now in version 1.7 is working again - just as quickly. +April 05, 2012 + +- Recovering a lost feature. In version 1.5, to improve the algorithms, a mistake broke formula handling. Now in version 1.7 it works again just as quickly. -- Added new functionality for programmers in the constructor of div class with - new parameter: IGNORE SOME VARIABLES. Example: +- Added a new feature for programmers in the constructor of div class with new parameter: IGNORE SOME VARIABLES. Example: +```php // ignoring the "name" variable -echo new div("index.tpl", array("name" => "Salvi", "age" => 25), array("name")); +echo new div("index.tpl", array( +"name" => "Rafael", +"age" => 25), array("name") +); +``` - Prevent a bugs with length two first parameters as filenames, in the div constructor - Release the 1.7 version ## Commits + - No commits found. diff --git a/releases/v1.8.0.md b/releases/v1.8.0.md index d88ee47..d28df09 100644 --- a/releases/v1.8.0.md +++ b/releases/v1.8.0.md @@ -1,33 +1,38 @@ # Release v1.8.0 + Date: 2012-04-07 ## Description -- Recovering a lost functionality. In version 1.5 to make the algorithms more efficient -we made a mistake and break functionality of the clean the orphan parts. Now in version 1.8 -is working again just as quickly. +April 07, 2012 + +- Recovering a lost feature. In version 1.5, to make the algorithms more efficient, we made a mistake and broke orphan-part cleanup. Now in version 1.8 it works again just as quickly. - Fix some grave bugs. -- Added new funtionalities: - - If a var contain an object, {$var} will be repleace with the count of properties - - Sub matches: now you can write ($var:0,20} or {$var:20} to replace this mark with - substr($var, 0, 20); +- Added new features: +- If a var contain an object, {$var} will be replaced with the count of properties +- Sub matches: now you can write ($var:0,20} or {$var:20} to replace this mark with substr($var, 0, 20); + +With this new feature you can chop a text in half thank to the formulas, for example: - With this new functionality you can chop a text in half thank - to the formulas, for example: +```div +{$text: (# {%text} / 2 #)} +{$text: (# {%text} / 2 #), (# {%text} / 2 #)} - {$text: (# {%text} / 2 #)} - {$text: (# {%text} / 2 #), (# {%text} / 2 #)} +``` - You can also make use of the variable's modifiers: +You can also make use of the variable's modifiers: - {^text: 1} +```div +{^text: 1} + +``` - Release the 1.8 version. -Note: The new added features made a little slower the engine. We are working -in the improvement of the algorithms. +Note: The new added features made a little slower the engine. We are working in the improvement of the algorithms. ## Commits + - No commits found. diff --git a/releases/v1.9.0.md b/releases/v1.9.0.md index 995fef8..0fcf305 100644 --- a/releases/v1.9.0.md +++ b/releases/v1.9.0.md @@ -1,120 +1,153 @@ # Release v1.9.0 + Date: 2012-04-09 ## Description +April 09, 2012 -- Fix some grave bugs of iterations functionality and other improvements. +- Fix some grave bugs in iteration features and other improvements. -- Added a new functionalitites: - - Custom item variable for lists and mark =>. For example: +- Added new features: +- Custom item variable for lists and mark =>. For example: - {= clients: [ - { - name: 'John', - products: [{name: 'Banana', price: 1.2},{name: 'Potato', price: 1.3}] - } - ] - =} +```html +{= clients: [ + { + name: 'John', + products: [{name: 'Banana', price: 1.2},{name: 'Potato', price: 1.3}] + } + ] +=} - [$clients] client => - [$products] - {$client.name} - {$name}
          - [/$products] - [/$clients] +[$clients] client => + [$products] + {$client.name} - {$name}
          + [/$products] +[/$clients] +``` - - Custom item variable for iterations: you now can specify the iteration variable. For example: +- Custom item variable for iterations: you now can specify the iteration variable. For example: - [:1,100,i:] - The current value is {$i} - [/] +```div +[:1,100,i:] + The current value is {$i} +[/] - - Nested iterations. The following example... +``` - [:1,10,i:] - [:1,10,j:] - {$i} * {$j} = (# {$i} * {$j} #)
          - [/] - [/] +- Nested iterations. The following example... - ...is similar to: +```html +[:1,10,i:] + [:1,10,j:] + {$i} * {$j} = (# {$i} * {$j} #)
          + [/] +[/] - "; +...is similar to: - ?> +```php +"; - - $_list, that it contains the list's name. +?> - For example: +``` - [$products] - {$_list} - [/$products] +- New variable for iterations and lists's cycle - Div associates a name to each iteration that you define. With this new functionality - you can know the name of the iteration inside the cycle of the iteration. +- $_list, that it contains the list's name. - Also, if you use the recursion, you can work now with the name of the list thanks to - this new variable that doesn't collapse with a variable inside the cycle. +For example: - For example: +```div +[$products] + {$_list} +[/$products] - {= list: "products", - products: [ - count: 3, - list: ["Banana", "Potato" , "Rice"] - ] - =} +``` - [{$list}] - {$_list} <--{ This shows the same thing that {$list} that is 'products' ... }--> - {$list} <--{ This shows the count of items of [$list] }--> - [$list] <--{ and this list is a list into the parent cycle }--> - {$value}, <--{ This shows Banana, Potato, Rice }--> - [/$list] - [/{$list}] +Div associates a name to each iteration that you define. With this new feature you can know the name of the iteration inside the cycle of the iteration. - - $_item, that it contains the list's item +Also, if you use the recursion, you can work now with the name of the list thanks to this new variable that doesn't collapse with a variable inside the cycle. - For example: +For example: - {= products: [ - { - name: "Banana", - price: 1.2 - }, - { - name: "Potato", - price: 1.3 - } - ] =} +```div +{= list: "products", + products: [ +``` - [$products] - {$_item} - {$_item.price} is similar to {$price} - [/$products] +count: 3, list: ["Banana", "Potato" , "Rice"] - - $_key, that it contains the item's key +```div + ] +=} - For example: +[{$list}] + {$_list} <--{ This shows the same thing that {$list} that is 'products' ... }--> + {$list} <--{ This shows the count of items of [$list] }--> + [$list] <--{ and this list is a list into the parent cycle }--> + {$value}, <--{ This shows Banana, Potato, Rice }--> + [/$list] +[/{$list}] - [$products] - [$_item] - {$_key}: {$value} - [/$_item] - [/$products] +``` -- Release the 1.9 version +- $_item, that it contains the list's item + +For example: + +```div +{= products: [ + { + name: "Banana", +``` + +price: 1.2 + +```div +}, +{ + name: "Potato", +``` + +price: 1.3 + +```div + } +] =} +[$products] + {$_item} + {$_item.price} is similar to {$price} +[/$products] +``` + +- $_key, that it contains the item's key + +For example: + +```div +[$products] + [$_item] + {$_key}: {$value} + [/$_item] +[/$products] + +``` + +- Release the 1.9 version ## Commits + - No commits found. diff --git a/releases/v2.0.0.md b/releases/v2.0.0.md index da9cdb1..e8ea7ee 100644 --- a/releases/v2.0.0.md +++ b/releases/v2.0.0.md @@ -1,44 +1,52 @@ # Release v2.0.0 + Date: 2012-04-14 ## Description +April 14, 2012 -- Added a new variable for the cycles: $_order, that is $_index + 1. - The index begins with 0. The order bigins with 1. This is util when you - need build a ordered list without
            tag and reused item template. +- Added a new variable for the cycles: $_order, that is $_index + 1. The index begins with 0. The order begins with 1. This is util, for example, when you need build a ordered list without
              tag and reused item template in HTML. - For example: +For example: - The ordered list: - --- +The ordered list: - [$list] - {% reused %} - [/$list] +```div +[$list] + {% reused %} +[/$list] +``` - The reused template reused.tpl: - --- +The reused template reused.tpl: - ?$_order {$_order}. $_order? Name: {$name} Address: {$address} +```div +?$_order {$_order}. $_order? Name: {$name} Address: {$address} +``` - On the other hand if you use the following template for reuse.tpl, - the first order number will be hidden and the template is more complicated: +On the other hand if you use the following template for reuse.tpl, the first order number will be hidden and the template is more complicated: - ?$_index (# {$_index} + #). $_index? Name: {$name} Address: {$address} +```div +?$_index (# {$_index} + #). $_index? Name: {$name} Address: {$address} -- Added new variable's modifiers: html and br +``` - {html:variable} convert all applicable chracters to HTML entities (see the - documentation of htmlentities() PHP function) +- Added new variable's modifiers: html and br - {br:variable} convert all \n to
              +```div +{html:variable} convert all applicable characters to HTML entities (see the +``` -- Fixed bugs of recursivity and recovered the high priority of variables into the cycles. +documentation of `htmlentities()` PHP function) -- Release the 2.0 Version +```html +{br:variable} convert all \n to
              +``` +- Fixed bugs of recursion and recovered the high priority of variables into the cycles. +- Release the 2.0 Version ## Commits + - No commits found. diff --git a/releases/v2.1.0.md b/releases/v2.1.0.md index 4921fb4..c0bc851 100644 --- a/releases/v2.1.0.md +++ b/releases/v2.1.0.md @@ -1,154 +1,205 @@ # Release v2.1.0 + Date: 2012-05-08 ## Description -- Change mixedBool() and parseMatch() methods for trim the string values. +May 08, 2012 + +- Added a new feature: pre-processed parts. + +Now you can pre-processed by div any part in template. The pre-processing are similar to include, but the pre-processing parse the code before including it. + +Include is: {% part.tpl %} (include and then parse) Pre-processing is {%% part.tpl %%} (parse and then include) + +IMPORTANT!: The pre-processing have a priority with regard to the list iterations. + +- Release the 2.1 version + +May 06, 2012 + +- Enable two new properties for PHP developers: $__src and $__packages. See the follow example: + +```php + +``` -- Enable two new properties for PHP developers: $__src and $__packages. - See the follow example: +- If you want that the names of the files have a prefix, specify it in constant PACKAGES or in the property $__packages of a class that extends the div. See the following examples: - +include "div.php"; -- If you want that the names of the files have a prefix, specify it in constant - PACKAGES or in the property $__packages of a class that extends the div. See - the following examples: +$tpl = new div("index"); // Div load the template from ./page_index.tpl - Example 1 - ---------------- - - $tpl = new div("index"); // Div load the template from ./page_index.tpl +``` - ... +Example 2 - ?> +```php + +... -- Add new constant DIV_DEFAULT_TPL_FILE_EXT for define a template file extension. - You can define this constant BEFORE include the div.php script. The default value - for this constant is the string "tpl". For example: +```div +} +``` - - include "div.php"; +``` - ... - ?> +- Add new constant DIV_DEFAULT_TPL_FILE_EXT for define a template file extension. You can define this constant BEFORE include the div.php script. The default value for this constant is the string "tpl". For example: -- Add new constant DIV_DEFAULT_DATA_FILE_EXT for define a data file extension. - You can define this constant BEFORE include the div.php script. The default value - for this constant is the string "json". For example: +```php + +... + +```div +?> + +``` + +- Add new constant DIV_DEFAULT_DATA_FILE_EXT for define a data file extension. You can define this constant BEFORE include the div.php script. The default value for this constant is the string "json". For example: + +```php + + +``` - Implement the show() method. - show(); +$tpl = new div("index.tpl"); +$tpl->show(); - ?> +?> -- If you don't pass the value of $src for the div class constructor, then - Div assumes that $src is the name of the class :) +``` - +echo new Page(); // Div try to load the template code from "Page.".DIV_DEFAULT_TPL_FILE_EXT file. -- Enable the div extends for OOP in the programmer side. The name of the properties - should not begin with __ (double underscore). See the follow example: +?> - Page.tpl - ------------- -

              {$title}{$body}

              +``` - Page.php - ------------- - +```html +

              {$title}{$body}

              - index.php - ------------- - title = "Hello world"; - $page->body = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.."; - $page->show(); // or echo $page; +```php + +class Page extends div{ + var $title; + var $body; +``` +var $__some; // This property will be ignored because its name begins with __ +```div +} -- Added a new functionality: pre-processed parts. +?> - Now you can pre-processed by div any part in template. The pre-processing - are similar to include, but the pre-processing parse the code before including it. +``` - Include is: {% part.tpl %} (include and then parse) - Pre-processing is {%% part.tpl %%} (parse and then include) +index.php - IMPORTANT!: The pre-processing have a priority with regard to the list interations. +```php +title = "Hello world"; +$page->body = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.."; +$page->show(); // or echo $page; +?> +``` + +April 21, 2012 + +- Change mixedBool() and parseMatch() methods for trim the string values. ## Commits + - No commits found. diff --git a/releases/v2.2.0.md b/releases/v2.2.0.md index 5673bc5..8435c58 100644 --- a/releases/v2.2.0.md +++ b/releases/v2.2.0.md @@ -1,266 +1,319 @@ # Release v2.2.0 + Date: 2012-05-14 ## Description -- Added aggregate functions for the lists: sum, avg, min, max, and the default count function +May 14, 2012 + +- Fixed bugs +- Release 2.2 version + +May 13, 2012 + +- New feature: assign to design vars the result of a method! If the programmer implemented a class that inherits of div, then the designer can use the methods of this class. + +Syntax for template: + +```div +{= variable: ->methodName(params as JSON) =} + +``` + +For example: - Now the designer can calculate another statistics from lists, for example: +Page.php - index.php - -------- - array( - array("name" => "Banana", "price" => 20.5), - .... - ... - ... - ), - "values" => array(10,20,30,40,50,60) - )); + public function getSum($params){ + return $params->x + $params->y; + } - ... - ?> - -------- + public function getLetters(){ + return array("A","B","C"); + } - index.tpl - -------- - Minimum price: {$min:products-price} - Maximum price: {$max:products-price} - Average of prices: {$avg:products-price} - Sum of prices: {$sum:products-price} - Count of products with price: {$count:products-price} or {$products-price} +} +?> - +``` - Minimum value: {$min:values} - Maximum value: {$max:values} - Average of values: {$avg:values} - Sum of values: {$sum:values} - -------- +Page.tpl -- Added a new constant constant DIV_CLASS_NAME for define the name of de superclass of div. - Now the programmer can change the name of the div class to avoid possible - collisions the class's names of his application. +```div +{= sum: ->getSum(x: 20, y: 30) =} -- Added a new functionality: default replacements by variable. +{$sum} - Now the programmer and the designer can define the default replacements for values - by variable. For example: +{= lts: ->getLetters() =} - Set the default replacement in PHP: +[$lts] {$value} [/$lts] - true)); - ?> +Output +```div +50 A B C - Or set the default replacement in the template: +``` - ... - {@["kept", true, "YES"]@} - {@["kept", false, "NO"]@} - ... +May 12, 2012 +- Now the definition of data in templates is similar to set a global var in the programmer side and you can re-refine this data every time in the template and now the sequence of the operations is not ignored. The variables have arrived! +For example: +-- TEMPALTE -- Now the definition of data in templates is similar to set a global var in the programmer side - and you can re-refine this data every time in the template and now the sequence of the operations - is not ignored. The variables have arrived! +```html + - For example: +{= products: [ + {price: 10, qty: 5}, + {price: 20, qty: 2} +] =} - -- - TEMPALTE - -- +{= invoice_price: 0 =} +{= tax: 20 =} - +[$products] {= invoice_price: (# {$invoice_price} +{$qty} * {$price} #) =} [/$products] - {= products: [ - {price: 10, qty: 5}, - {price: 20, qty: 2} - ] =} +Invoice price: {#invoice_price:2.#}
              - {= invoice_price: 0 =} - {= tax: 20 =} +Tax: {#tax:2.#}
              - [$products] {= invoice_price: (# {$invoice_price} +{$qty} * {$price} #) =} [/$products] + - Invoice price: {#invoice_price:2.#}
              +{= invoice_price: (# {$invoice_price} + {$tax} #) =} - Tax: {#tax:2.#}
              +Total price: {#invoice_price:2.#} - +``` - {= invoice_price: (# {$invoice_price} + {$tax} #) =} +-- OUTPUT - Total price: {#invoice_price:2.#} +```div - -- - OUTPUT - -- - Invoice price: 90.00 - Tax: 20.00 - Total price: 110.00 +Invoice price: 90.00 +Tax: 20.00 +Total price: 110.00 +``` - Fixed bugs -- Add new functionality: capsules!, with the symbol of Div logo!.... of course! +- Add new feature: capsules!, with the symbol of Div logo!.... of course! + +Now you can create capsules inside the insole to reduce the code and to facilitate the work with objects and arrangements. A capsule consists on a block that fulfills the following syntax: + +```div +[[variable + +``` + +... In this section you can use the properties of variable if it is an object or their keys if it is an array ... + +variable]] + +For example: + +index.php + +```php + array( "name" => "Banana", "price" => 20.4 - Now you can create capsules inside the insole to reduce the code and to facilitate - the work with objects and arrangements. A capsule consists on a block that fulfills - the following syntax: +```div + ) +)); +``` - [[variable +... - ... In this section you can use the properties of variable if it is - an object or their keys if it is an array ... +```div +?> - variable]] +``` - For example: +index.tpl - index.php - ------------------- +```html +[[product + Name: {$name}
              + Price: {$price}
              +``` - array( - "name" => "Banana", - "price" => 20.4 - ) - )); - ... - ?> +product]] - index.tpl - --------------------- +Enjoy! - [[product - Name: {$name}
              - Price: {$price}
              - product]] +- Add a new iteration feature: now you can specify a STEP for iteration. - Enjoy! +Syntax: -- Add new feature for iterations functionality: now you can specify a STEP for iteration. +Variant 1: - Syntax: - ------------------ +```div +[:from,to,var,step:] + +``` - Variant 1: +Variant 2: - [:from,to,var,step:] +```div +[:from,to,step:] - Variant 2: +``` - [:from,to,step:] +Example 1: - Example 1: - ---------------- +Template: - Template: +```div +[:1,10,2:] {$value} [/] - [:1,10,2:] {$value} [/] +``` - Output: +Output: - 1 3 5 7 9 +```div +1 3 5 7 9 - Example 2: - ----------------- +Example 2: +``` - [:1,10,i,2:] {$i} [/] +```div +[:1,10,i,2:] {$i} [/] - Output: +``` - 1 3 5 7 9 +Output: - Example 3: - ----------------- - [:10,1,i,2:] {$i} [/] +```div +1 3 5 7 9 - 10 8 6 4 2 +Example 3: +``` + +```div +[:10,1,i,2:] {$i} [/] + +``` + +10 8 6 4 2 - Another way to define the iteration var with high priority. Now the follow templates are similars: - Template 1: +Template 1: - [:1,10,x:] .... [/] +```div +[:1,10,x:] .... [/] - Template 2: +``` - [:1,10:] x => .... [/] +Template 2: - The follow example shows the priority of this new way: +```div +[:1,10:] x => .... [/] - Template: +``` - [:1,10,x:] y => {$y} {$x} [/] +The follow example shows the priority of this new way: - Output: +Template: - 1 {$x} 2 {$x} 3 {$x} 4 {$x} 5 {$x} 6 {$x} 7 {$x} 8 {$x} 9 {$x} 10 {$x} +```div +[:1,10,x:] y => {$y} {$x} [/] +``` +Output: -- New functionality: assign to design vars the result of method! If the programmer - implemented a class that inherits of div, then the designer can use the methods of this - class. +```div +1 {$x} 2 {$x} 3 {$x} 4 {$x} 5 {$x} 6 {$x} 7 {$x} 8 {$x} 9 {$x} 10 {$x} + - Syntax for template: +``` - {= variable: ->methodName(params as JSON) =} +May 09, 2012 - For example: +- Added aggregate functions for the lists: sum, avg, min, max, and the default count function - Page.php - -------------------------- - x + $params->y; - } +index.php - public function getLetters(){ - return array("A","B","C"); - } +```php + +``` - Page.tpl - --------------------------- +... echo new div("index.tpl", array( "products" => array( array("name" => "Banana", "price" => 20.5), .... ... ... - {= sum: ->getSum(x: 20, y: 30) =} +```div + ), + "values" => array(10,20,30,40,50,60) +)); - {$sum} +``` - {= lts: ->getLetters() =} +... - [$lts] {$value} [/$lts] +```div +?> +``` - Output - --------------------------- - 50 A B C +index.tpl +Minimum price: {$min:products-price} Maximum price: {$max:products-price} Average of prices: {$avg:products-price} Sum of prices: {$sum:products-price} Count of products with price: {$count:products-price} or {$products-price} -- Fixed bugs -- Release 2.2 version +```div + + +Minimum value: {$min:values} +Maximum value: {$max:values} +Average of values: {$avg:values} +Sum of values: {$sum:values} +``` + +- Added a new constant constant DIV_CLASS_NAME for define the name of de superclass of div. Now the programmer can change the name of the div class to avoid possible collisions the class's names of his application. + +- Added a new feature: default replacements by variable. + +Now the programmer and the designer can define the default replacements for values by variable. For example: +Set the default replacement in PHP: +```php + true)); + +```div +?> + +``` + +Or set the default replacement in the template: + +... + +```div +{@["kept", true, "YES"]@} +{@["kept", false, "NO"]@} +``` + +... ## Commits + - No commits found. diff --git a/releases/v2.3.0.md b/releases/v2.3.0.md index 48b2151..88a0236 100644 --- a/releases/v2.3.0.md +++ b/releases/v2.3.0.md @@ -1,86 +1,121 @@ # Release v2.3.0 + Date: 2012-05-22 ## Description -- NEW: Allowed functions. Now the programmer can enable functions - of or written in PHP so that the designer can use them in the templates. +May 22, 2012 - +```php + 5)); ... -- NEW: Add new item to list or set a property of object: +```div +?> - TEMPLATE - ------------- - ... some more code here ... +``` - {= list: [1,2,3] =} - {= customer: { - name: "Peter", - phone: "222-444555" - } =} +index.tpl - ... some more code here ... +```div +{= another: $some =} - {= list[]: 4 =} - {= customer[address]: #221 street 45 =} +{$another} - ... some more code here ... +``` - {$list.4} +Output - {$customer.address} +```div +5 +Also you can asign to the specific property of template var: +``` -- NEW: Allow to asign a program var to a template var. For example: +index.tpl - index.php - ------------- - 5)); - ... - ?> +```div +{= someobj: { + property: "$some" +} =} - index.tpl - ------------- +{$someobj.property} - {= another: $some =} +``` - {$another} +- Release the 2.3 version - Output - ------------- - 5 +May 19, 2012 - Also you can asign to the specific property of template var: +- NEW: Allowed functions. Now the programmer can enable functions of or written in PHP so that the designer can use them in the templates. - index.tpl - -------------- - {= someobj: { - property: "$some" - } =} +```php + + +``` + +index.tpl + +```div +(# sum(2,3) #) +``` +- NEW: Add new item to list or set a property of object: + +TEMPLATE + +... some more code here ... + +```div +{= list: [1,2,3] =} +{= customer: { + name: "Peter", + phone: "222-444555" +} =} + +``` + +... some more code here ... + +```div +{= list[]: 4 =} +{= customer[address]: #221 street 45 =} + +``` + +... some more code here ... + +```div +{$list.4} + +{$customer.address} + +``` ## Commits + - No commits found. diff --git a/releases/v2.4.0.md b/releases/v2.4.0.md index 0bdc508..e9e59a6 100644 --- a/releases/v2.4.0.md +++ b/releases/v2.4.0.md @@ -1,31 +1,42 @@ # Release v2.4.0 + Date: 2012-06-08 ## Description -- Added new functionality: show the teaser of a text. Similar to get a substring of text: +Jun 8, 2012 - {$mytext:100} +- Fixed bugs +- Added new feature: text wrap - If you add the symbol ~, you can retrieve the teaser of $mytext: +If you needed the wrap of a text with a specific width, you can do this: - {$mytext:~100} +```div +{$body:/200} +``` -- Fixed bugs -- Added new functionality: text wrap +If you use the br modifier, the text wrap take effect on the web: - If you needed the wrap of a text with a specific width, you can do this: +```div +{br:body:/200} +``` - {$body:/200} +- Release the 2.4 version - If you use the br modifier, the text wrap take effect on the web: +May 27, 2012 - {br:body:/200} -- Release the 2.4 version +- Added new feature: show the teaser of a text. Similar to getting a substring of text: + +```div +{$mytext:100} +If you add the symbol ~, you can retrieve the teaser of $mytext: +{$mytext:~100} +``` ## Commits + - No commits found. diff --git a/releases/v2.5.0.md b/releases/v2.5.0.md index d5e263e..2cbb922 100644 --- a/releases/v2.5.0.md +++ b/releases/v2.5.0.md @@ -1,27 +1,36 @@ # Release v2.5.0 + Date: 2012-06-30 ## Description +Jun 30, 2012 + - Fixed bugs -- Added new functionality: html to text +- Added new feature for logging: save the steps of the parser into a log file - {txt} ... some html code here .. {/txt} - {txt} width => ... some html code here {/txt} +```div +// Save the steps of the parser into log file +div::logOn("mylogfile.log"); +``` - The width integer parameter, wrap the text with this width. +... +- Release the 2.5 version +Jun 13, 2012 - Fixed bugs -- Added new funcionality for log: Save the steps of the parser into log file +- Added new feature: HTML to text - // Save the steps of the parser into log file - div::logOn("mylogfile.log"); - ... -- Release the 2.5 version +```div +{txt} ... some html code here .. {/txt} +{txt} width => ... some html code here {/txt} +``` +The width integer parameter, wrap the text with this width. ## Commits + - No commits found. diff --git a/releases/v2.6.0.md b/releases/v2.6.0.md index 7a3b4ea..ea384f1 100644 --- a/releases/v2.6.0.md +++ b/releases/v2.6.0.md @@ -1,64 +1,73 @@ # Release v2.6.0 + Date: 2012-07-26 ## Description -- Add new features for performance: enable and disable system var - - div::enableSystemVar("div.session"); - div::disableSystemVar("div.server"); - ... +Jul 26, 2012 +- Fixed bugs +- Release the 2.6 version +Jul 08, 2012 - Added new features for replacements: multiple replacements - +```div + - {= replac: [ - ['search this string', 'replace with this string', false], - ] =] +{= replac: [ + ['search this string', 'replace with this string', false], +] =] - + - {:replac} +{:replac} - ... some code here .... +``` - {:/replac} +... some code here .... +```div +{:/replac} - Example: - ---------- +``` - {= php-code: [ - ['echo ', 'echo '], - ['/\'([^\'](?:\\.|[^\\\']*)*)\'/i', '\'$1\'',true] - ] =} +Example: - {:php-code} +```php +{= php-code: [ + ['echo ', 'echo '], + ['/\'([^\'](?:\\.|[^\\\']*)*)\'/i', '\'$1\'',true] + ] =} - +{:php-code} - {:/php-code} + - Output: - ---------- +{:/php-code} - echo 'hello world' - ?> -- Fixed bugs +``` +Output: +```php +echo 'hello world' +?> +``` - Fixed bugs -- Release the 2.6 version +Jul 02, 2012 +- Add new features for performance: enable and disable system var + +div::enableSystemVar("div.session"); div::disableSystemVar("div.server"); ... ## Commits + - No commits found. diff --git a/releases/v2.7.0.md b/releases/v2.7.0.md index 8945bfb..d60e722 100644 --- a/releases/v2.7.0.md +++ b/releases/v2.7.0.md @@ -1,29 +1,37 @@ # Release v2.7.0 + Date: 2012-08-03 ## Description -- Fixed bugs -- Add new feature for json encode. +Aug 03, 2012 - Example: +- Fixed bugs +- Release the 2.7 version - array(1,2,3,4,5))); +- Fixed bugs +- Add new feature for json encode. - {json:variable} +Example: - Outoput: +```php + array(1,2,3,4,5))); +{json:variable} +``` -- Fixed bugs -- Release the 2.7 version +Outoput: +```div +[1,2,3,4,5] +``` ## Commits + - No commits found. diff --git a/releases/v2.8.0.md b/releases/v2.8.0.md index aec8920..3d75ee1 100644 --- a/releases/v2.8.0.md +++ b/releases/v2.8.0.md @@ -1,60 +1,83 @@ # Release v2.8.0 + Date: 2012-08-16 ## Description +Aug 16, 2012 + +- Change the type of method of mixedBool from public to static. +- Release the 2.8 version + +Aug 09, 2012 + +- Added new feature: Relative paths for include and preprocessed templates. + +Aug 07, 2012 + +- Freed of the function json_encode of PHP and corrected some errors of this function. + +Aug 05, 2012 + - Fixed bugs: - - If you don't define a variable, the expression is FALSE: +- If you don't define a variable, the expression is FALSE: - Example: - "some")); // var2 is missing +```php + "some")); // var2 is missing - {?( "{$var1}" == "some" && "{$var2}" == "another" )?) - Part 1 - @else@ - Part 2 - {/?} +``` - Output: - ---------- - Part 2 +index.tpl - - If you don't define a variable, the formula will be ignored: +```div +{?( "{$var1}" == "some" && "{$var2}" == "another" )?) +``` - Example: - 2)); // var2 is missing +```div +@else@ +``` - index.tpl - ---------- +Part 2 - (# {$var1} + {$var2} #) +```div +{/?} - Output: - ---------- +``` - (# 2 + {$var2} #) +Output: +Part 2 +- If you don't define a variable, the formula will be ignored: -- Freed of the function json_encode of PHP and corrected some errors of this function. +Example: +```php + 2)); // var2 is missing -- Added new feature: Relative paths for include and preprocessed templates. +``` +index.tpl +```div +(# {$var1} + {$var2} #) -- Change the type of method of mixedBool from public to static. -- Release the 2.8 version +``` +Output: +```div +(# 2 + {$var2} #) +``` ## Commits + - No commits found. diff --git a/releases/v2.9.0.md b/releases/v2.9.0.md index 37d8171..3598e27 100644 --- a/releases/v2.9.0.md +++ b/releases/v2.9.0.md @@ -1,101 +1,134 @@ # Release v2.9.0 + Date: 2012-09-02 ## Description -- Change the type of method of getSystemData from public to static +Sep 2, 2012 +- Fix bugs +- Release the 2.9 version -- The algorithm of text summary was improved. -- New feature: IDE's friendly marks +Aug 30, 2012 - Example: +- Improvements to the template's vars. Now you can do this: - +article.tpl -

              Name: {$name}

              -

              Price: {$price}

              +```html +

              {$title}

              +

              {$body}

              - - Expensive product - +``` - +page.tpl - Is similar to: +```div +{= content: article =} -

              Name: {$name}

              -

              Price: {$price}

              +Header - {?( {$price} > 10 )?} - Expensive product - {/?} +```div +{$content} - [/$products] +``` +Footer +Aug 20, 2012 -- Delete the DIV_CLASS_NAME constant: now is more simple to change the name of - div class. Simply change the name of div class, no more! +- Delete the DIV_CLASS_NAME constant: now is more simple to change the name of div class. Simply change the name of div class, no more! - Fix problem of template vars's scope. The inheritance mechanism is more simple now: - ------------------- - parent.tpl - ------------------- - - {= block1: +parent.tpl - ...some code here... +```div + +{= block1: - =} +``` - - {$block1} +...some code here... - ------------------- - child.tpl - ------------------- - - {= *block1: +=} - ...some another code here... +```div + +{$block1} - =} +``` - - {% parent %} +child.tpl +```div + +{= *block1: +``` -- Improvements to the template's vars. Now you can do this: +...some another code here... - article.tpl - ----------------- +=} -

              {$title}

              -

              {$body}

              +```div + +{% parent %} +``` - page.tpl - ------------------ - {= content: article =} +Aug 18, 2012 - Header +- The algorithm of text summary was improved. +- New feature: IDE's friendly marks - {$content} +Example: - Footer +```html + +

              Name: {$name}

              +

              Price: {$price}

              + + +``` +Expensive product -- Fix bugs -- Release the 2.9 version +```div + + + +``` + +Is similar to: + +```html +[$products] + +

              Name: {$name}

              +

              Price: {$price}

              + + {?( {$price} > 10 )?} +``` + +Expensive product + +```div + {/?} + +[/$products] + +``` + +Aug 17, 2012 + +- Change the type of method of getSystemData from public to static ## Commits + - No commits found. diff --git a/releases/v3.0.0.md b/releases/v3.0.0.md index ab8e979..05033f8 100644 --- a/releases/v3.0.0.md +++ b/releases/v3.0.0.md @@ -1,47 +1,56 @@ # Release v3.0.0 + Date: 2012-11-04 ## Description -- Fix bugs of conditions into loops - - -- Fix important issue for matchs. Now work the follow example: - - {= list: [ - { - name: "Banana", - price: 20, - shipments: [ - { - date: "2012-05-09", - packages: [ - [20, 30, 40] - ] - } - ] - }, - { - name: "Potato", - price: 40 - } - ] =} - - {$list}
              - {$list.0}
              - {$list.0.shipments}
              - {$list.0.shipments.0}
              - {$list.0.shipments.0.adresses}
              - {$list.0.shipments.0.adresses.0}
              - {$list.0.shipments.0.adresses.0.0}
              - - +Nov 4, 2012 - Fix some problems - Improvement of some mechanisms - Release the 3.0 version +Sep 7, 2012 + +- Fix important issue for matches. Now work the follow example: + +```div +{= list: [ + { + name: "Banana", + price: 20, + shipments: [ + { + date: "2012-05-09", + packages: [ + [20, 30, 40] + ], + addresses: [ + "123 Main St", + "456 Elm St" + ] + } + ] +}, +{ + name: "Potato", + price: 40 + } +] =} + +{$list}
              +{$list.0}
              +{$list.0.shipments}
              +{$list.0.shipments.0}
              +{$list.0.shipments.0.addresses}
              +{$list.0.shipments.0.addresses.0}
              +{$list.0.shipments.0.addresses.0.0}
              +``` + +Sep 2, 2012 +- Fix bugs of conditions into loops ## Commits + - No commits found. diff --git a/releases/v3.1.0.md b/releases/v3.1.0.md index 2b572e2..cfcf80b 100644 --- a/releases/v3.1.0.md +++ b/releases/v3.1.0.md @@ -1,29 +1,34 @@ # Release v3.1.0 + Date: 2012-11-21 ## Description -- Allowed "intval" PHP function in formulas - - - -- Improved the algorithm of lists/loops/cycles +Nov 21, 2012 +- Update documentation +- Release 3.1 version +Nov 21, 2012 - Detection of recursive inclusion as an error. For example: - index.tpl - ------------- - - {% index %} +index.tpl +```div + +{% index %} +``` -- Update documentation -- Release 3.1 version +Nov 19, 2012 +- Improved the algorithm of lists/loops/cycles +Nov 16, 2012 + +- Allowed "intval" PHP function in formulas ## Commits + - No commits found. diff --git a/releases/v3.2.0.md b/releases/v3.2.0.md index f13803f..d701164 100644 --- a/releases/v3.2.0.md +++ b/releases/v3.2.0.md @@ -1,41 +1,49 @@ # Release v3.2.0 + Date: 2013-02-04 ## Description -- Improved date's values detection +February 4, 2013 +- Fix a bug with the {ignore} feature +- Add new vars for the iterations: $_previous and $_next. +index.tpl -- Fix a bug with {ignore} functionality -- Add new vars for the iterations: $_previous and $_next. +```div +{= list: [10,5,7,12,8,8,10,10] =} +[$list] + {= _previous: 0 =} + {= _next: infinite =} + {$_previous}..{$value}..{$_next} +[/$list] + +``` - index.tpl - ------- - {= list: [10,5,7,12,8,8,10,10] =} - [$list] - {= _previous: 0 =} - {= _next: infinite =} - {$_previous}..{$value}..{$_next} - [/$list] - - Output - ------ - 0..1..2 - 1..2..3 - 2..3..4 - 3..4..5 - 4..5..6 - 5..6..7 - 6..7..8 - 7..8..9 - 8..9..10 - 9..10..infinite +Output + +```div +0..1..2 +1..2..3 +2..3..4 +3..4..5 +4..5..6 +5..6..7 +6..7..8 +7..8..9 +8..9..10 +9..10..infinite + +``` - Algorithm improved: 95% more faster. - Release the 3.2 version +Dec 26, 2012 +- Improved date's values detection ## Commits + - No commits found. diff --git a/releases/v3.3.0.md b/releases/v3.3.0.md index f3bd9fe..d7675b6 100644 --- a/releases/v3.3.0.md +++ b/releases/v3.3.0.md @@ -1,12 +1,14 @@ # Release v3.3.0 + Date: 2013-02-15 ## Description +February 15, 2013 + - Fix a critical bug: prevented infinite cycle - Release the 3.3 version - - ## Commits + - No commits found. diff --git a/releases/v3.4.0.md b/releases/v3.4.0.md index 640ffb1..f1c3300 100644 --- a/releases/v3.4.0.md +++ b/releases/v3.4.0.md @@ -1,37 +1,48 @@ # Release v3.4.0 + Date: 2013-02-19 ## Description +February 19, 2013 + +- The documentation was updated +- Improved detection of infinite loops on includes and replacements +- Release the 3.4 version + +February 17, 2013 + - Add new feature: Multiple variable's modifiers - Syntax: - ---------- - {$varname|modifier1|modifier2|modifier3|...|} +Syntax: - index.tpl - ---------- - {= word: "ABCDEFG" =} +```div +{$varname|modifier1|modifier2|modifier3|...|} - {$word|0,3|} - {$word|0,3|_|} - {$word|0,3|_|^|} - {$word|0,3|_|^|~2|} +``` - Output - ------- - ABC - abc - Abc - Ab +index.tpl +```div +{= word: "ABCDEFG" =} +{$word|0,3|} +{$word|0,3|_|} +{$word|0,3|_|^|} + {$word|0,3|_|^|~2|} -- The documentation was updated -- Improved detection of infinite loops on includes and replacements -- Release the 3.4 version +``` + +Output +```div +ABC +abc +Abc +Ab +``` ## Commits + - No commits found. diff --git a/releases/v3.5.0.md b/releases/v3.5.0.md index 9344f27..d3419e6 100644 --- a/releases/v3.5.0.md +++ b/releases/v3.5.0.md @@ -1,79 +1,105 @@ # Release v3.5.0 + Date: 2013-03-08 ## Description -- New feature: @empty@ tag for list's blocks - - [$users] - {$name} - @empty@ - Show this if list users is empty - [/$users] +March 8, 2013 +- Update the documentation +- Fixes some bugs of new features +- Release the 3.5 version +February 24, 2013 - New feature: locations! - Now you can define a diferent locations in your template - and put in this locations any content. +Now you can define a diferent locations in your template and put in this locations any content. + +Example: + +```div +(( top )) + +(( any )) Some content here (( any )) + +(( bottom )) + +{{top +``` +This is the top of the page top}} - Example: - ----------------- - (( top )) +```div +{{bottom +``` - (( any )) Some content here (( any )) +This is the bottom of the page bottom}} - (( bottom )) +```html +{{any +
              +any}} - {{top - This is the top of the page - top}} +``` - {{bottom - This is the bottom of the page - bottom}} +Output: - {{any -
              - any}} +```html +This is the top of the page - Output: - ----------------- - This is the top of the page +
              Some content here
              -
              Some content here
              +This is the bottom of the page - This is the bottom of the page +``` - Improvement of the conditional parts: the first and last blank space are removed. - In Div 1.0 to 3.4: - --------------------- +In Div 1.0 to 3.4: - ?$what Hello $what? +```html +?$what Hello $what? - Output: - --------------------- - Hello +``` - From Div 3.5: - --------------------- +Output: - ?$what Hello $what? +```html + Hello - Output: - --------------------- - Hello +``` +From Div 3.5: +```html +?$what Hello $what? -- Update the documentation -- Fixes some bugs of new features -- Release the 3.5 version +``` +Output: +```html +Hello + +``` + +February 24, 2013 + +- New feature: @empty@ tag for list's blocks + +```div +[$users] + {$name} +@empty@ +``` + +Show this if list users is empty + +```div +[/$users] +``` ## Commits + - No commits found. diff --git a/releases/v3.6.0.md b/releases/v3.6.0.md index faad8d5..e2ad8d6 100644 --- a/releases/v3.6.0.md +++ b/releases/v3.6.0.md @@ -1,99 +1,117 @@ # Release v3.6.0 + Date: 2013-03-16 ## Description -- Improved the detection of orphan conditional parts +March 16, 2013 +- Improved the access to object's public methods +index.php -- Improved the feature "template vars". Now you can execute the "methods of information". +```php +first_name = $first_name; + $this->last_name = $last_name; + } + function getCompleteName(){ + return $this->first_name.' '.$this->last_name; + } +} - include "div.php"; +echo new div('index.tpl', array( +'person' => new Person('John', 'Nash') +)); - class MyData { +``` - var $somedata = 100; +index.tpl - function getNames(){ - return array("Jones", "Pete", "Mark"); - } - } +```div +[[person - echo new div('index.tpl', new MyData()); + {= cn: ->getCompleteName() =} + + First Name: {$first_name} + Last Name: {$last_name} + Complete name: {$cn} - ?> +``` - index.tpl - ------------------ +person]] - somedata is: {$somedata} +Output - {= names: ->getNames() =} +```div +First Name: John +Last Name: Nash +Complete name: John Nash - The names are: [$names] {$value} [/$names] +``` +- Release the 3.6 version - Output - -------------------- - somedata is: 100 +March 13, 2013 - The names are: Jones Pete Mark +- Improved the feature "template vars". Now you can execute the "methods of information". +Example: +index.php +```php +first_name = $first_name; - $this->last_name = $last_name; - } - function getCompleteName(){ - return $this->first_name.' '.$this->last_name; - } - } + function getNames(){ + return array("Jones", "Pete", "Mark"); + } +} - echo new div('index.tpl', array( - 'person' => new Person('John', 'Nash') - )); +echo new div('index.tpl', new MyData()); - index.tpl - --------------------- - [[person +?> - {= cn: ->getCompleteName() =} +``` - First Name: {$first_name} - Last Name: {$last_name} - Complete name: {$cn} +index.tpl - person]] +somedata is: {$somedata} - Output - ---------------------- - First Name: John - Last Name: Nash - Complete name: John Nash +```div +{= names: ->getNames() =} -- Release the 3.6 version +The names are: [$names] {$value} [/$names] + +``` +Output + +```div +somedata is: 100 + +The names are: Jones Pete Mark + +``` + +March 13, 2013 + +- Improved the detection of orphan conditional parts ## Commits + - No commits found. diff --git a/releases/v3.7.0.md b/releases/v3.7.0.md index 8c54dd8..a5d174b 100644 --- a/releases/v3.7.0.md +++ b/releases/v3.7.0.md @@ -1,282 +1,364 @@ # Release v3.7.0 + Date: 2013-03-30 ## Description -- Added new variable's modifiers: +March 30, 2013 - {&&var} - rawurlencode - {'var} - escape unescaped single quotes - {js:var} - escape quotes and backslashes, newlines, etc. - {$var:[string format]} - format the value with sprintf PHP function +- Improved the interpretation of third parameter of the constructor as a string with the variables's names. -- Added new feature for programmers: custom variable's modifier +echo new div('index.tpl', array('name' => 'Peter', 'age' => 25, 'sex' => 'M'), 'name,age'); - For add a new custom variable's modifier you need call the method: +- Release the 3.7 version - div::addCustomModifier($prefix, $function) +March 26, 2013 - The parameter $function can be the name of function or the name of static method of a class, for example +- Improvement of the speed. +- Improvement of the options around the __toString method of objects in 3 scopes. See the example below. - div::addCustomModifier('upper', 'MyModifiers::upper'); +The old policy: - Example: - ---------------- - index.php +"if an object has implemented the method __toString then be treated as a string" - 'http://localhost')); +index.php - ?> +```php +name = $name; + $this->price = $price; + } + public function __toString(){ + return $this->name.' ($'.$this->price.')'; + } +} - Output - ----------- - http%3A//localhost +// The object as string +echo new div('index.tpl', array("product" => new Product('Banana', 10))); -- Added new feature for programmers: the hooks!. The hooks are: +// Template scope +echo new div('index1.tpl', array(new Product('Banana', 10))); - beforeBuild, afterBuild, beforeParse, afterParse +// Capsule scope +echo new div('index2.tpl', array("product" => new Product('Banana', 10))); - Example: +// Loop's body scope +echo new div('index3.tpl', array("products" => array(new Product('Banana', 10)))); - index.php - --------------- - class HomePage extends div{ +?> - public function beforeBuild(){ - $this->__src = "index"; - $this->setItem(array( - "title" => "Hello World" - )); - } - } +``` - echo new HomePage(); +index.tpl - index.tpl - --------------- -

              {$title}

              +```div +{$product} - Output - ---------------- -

              Hello World

              +``` -- Improvement of the setItem method +Output for index.tpl +```div +Banana ($10) +``` -- Added a new feature for programmers: the method changeTemplate() +index1.tpl - "Hello world")); +is similar to - echo $tpl; // $tpl->show(); +```div +{$_to_string} - $tpl->changeTemplate('index2.tpl'); +``` - echo $tpl; // $tpl->show(); +index2.tpl - ?> +```div +[[product -- Improvement of the show() method with a new parameter: specific template +{$value} + +``` + +is similar to + +```div +{$_to_string} + +``` + +product]] - name = $name; + $this->price = $price; + } + + public function __toString(){ + return $this->name.' ($'.$this->price.')'; + } +} - $tpl = new div(); - $tpl->title = "Hello world"; - $tpl->show('template.tpl'); +echo new div('index.tpl', array("products" => array(new Product('Banana', 10)))); +?> - ?> +``` +index.tpl + +```div +[$products] + {$value} +[/$products] + +``` + +Output + +```div +Banana ($10) + +We are working to improve the policy and avoid unhappy. + +``` + +March 22, 2013 - Some functions of PHP are enabled in formulas and conditions. - Added a new system var named: $div.ascii. This var contain the all chars of ASCII table. - +?> - index.tpl - ----------- - {$div.ascii.64} +``` - is similar to +index.tpl - (# chr(64) #) +```div +{$div.ascii.64} - but the replacement is faster than calculation +``` - Output: - ------- - @ +is similar to - is similar to +```div +(# chr(64) #) - @ +``` - but the replacement is faster than calculation +but the replacement is faster than calculation +Output: +```div +@ -- From version 3.6 Div maintains a policy regarding the use of objects: if an -object has implemented the method __ toString then be treated as a character string. -We are working to improve the policy and avoid unhappy. +``` - index.php +is similar to - name = $name; - $this->price = $price; - } +but the replacement is faster than calculation - public function __toString(){ - return $this->name.' ($'.$this->price.')'; - } - } +March 20, 2013 - echo new div('index.tpl', array("products" => array(new Product('Banana', 10)))); - ?> +- Added a new feature for programmers: the method changeTemplate() - index.tpl +```php + "Hello world")); - We are working to improve the policy and avoid unhappy. +echo $tpl; // $tpl->show(); +$tpl->changeTemplate('index2.tpl'); -- Improvement of the speed. -- Improvement of the options arround the __toString method of objects in 3 scopes. See the example below. +echo $tpl; // $tpl->show(); - The old policy: +?> - "if an object has implemented the method __toString then be treated as a string" +``` - It was changed for: +- Improvement of the show() method with a new parameter: specific template - "if an object has implemented the method __toString, you can work with the object as a character string" +```php +title = "Hello world"; +$tpl->show('template.tpl'); - index.php - --------- - - include "div.php"; +``` - class Product{ - public function __construct($name, $price){ - $this->name = $name; - $this->price = $price; - } +March 18, 2013 - public function __toString(){ - return $this->name.' ($'.$this->price.')'; - } - } +- Added new variable's modifiers: - // The object as string - echo new div('index.tpl', array("product" => new Product('Banana', 10))); +```div +{&&var} - rawurlencode +{'var} - escape unescaped single quotes +{js:var} - escape quotes and backslashes, newlines, etc. +{$var:[string format]} - format the value with sprintf PHP function - // Template scope - echo new div('index1.tpl', array(new Product('Banana', 10))); +``` - // Capsule scope - echo new div('index2.tpl', array("product" => new Product('Banana', 10))); +- Added new feature for programmers: custom variable's modifier - // Loop's body scope - echo new div('index3.tpl', array("products" => array(new Product('Banana', 10)))); +For add a new custom variable's modifier you need call the method: - ?> +```div +div::addCustomModifier($prefix, $function) - index.tpl - ------------ - {$product} +``` - Output for index.tpl - -------------------- - Banana ($10) +The parameter $function can be the name of function or the name of static method of a class, for example - index1.tpl - ---------- - {$value} +div::addCustomModifier('upper', 'MyModifiers::upper'); - is similar to +Example: - {$_to_string} +index.php - index2.tpl - ---------- - [[product +```php + 'http://localhost')); - product]] +?> - index3.tpl - ---------- - [$products] - {$value} +``` - is similar to +index.tpl - {$_to_string} - [/$products] +```div +{upi:url} - Same output for index1, index2 and index3 - ------------- - Banana ($10) +``` - is similar to +Output - Banana ($10) +```div +http%3A//localhost +``` -- Improved the interpretation of third parameter of the constructor - as a string with the variables's names. +- Added new feature for programmers: the hooks!. The hooks are: - echo new div('index.tpl', array('name' => 'Peter', 'age' => 25, 'sex' => 'M'), 'name,age'); +beforeBuild, afterBuild, beforeParse, afterParse -- Release the 3.7 version +Example: + +index.php + +class HomePage extends div{ + +public function beforeBuild(){ + +```div + $this->__src = "index"; + $this->setItem(array( + "title" => "Hello World" + )); + } +} + +echo new HomePage(); +``` +index.tpl + +```html +

              {$title}

              + +``` + +Output + +```html +

              Hello World

              + +``` + +- Improvement of the setItem method ## Commits + - No commits found. diff --git a/releases/v3.8.0.md b/releases/v3.8.0.md index 48a9080..69c0f0e 100644 --- a/releases/v3.8.0.md +++ b/releases/v3.8.0.md @@ -1,13 +1,15 @@ # Release v3.8.0 + Date: 2013-04-03 ## Description +April 03, 2013 + - Version 3.7 was released with a serious error that was corrected in the 3.8 - Release the 3.8 version - - ## Commits + - No commits found. diff --git a/releases/v3.9.0.md b/releases/v3.9.0.md index 5ccaace..9fb0c77 100644 --- a/releases/v3.9.0.md +++ b/releases/v3.9.0.md @@ -1,361 +1,424 @@ # Release v3.9.0 + Date: 2013-05-18 ## Description -- The scalar values as a complex values! What? +May 18, 2013 - Yes! Now all the scalar values can be used as strings. Then, the strings can be - used like complex values, that is to say, as group of characters. For example: +- Created a tool to build dialects. +- Release the 3.9 version - index.tpl - -------------- - {= name: "Peter" =} +May 10, 2013 - - {$name.0} +- Enable custom dialect for developers! - - {$name.1} +A dialect is defined by the group of constant whose name begins with DIV_TAG. This dialect is subject to some simple rules that Div forces to complete for preveer inconsistencies and infinite loops. - {= x: 537 =} +- New static method isValidCurrentDialect, for detect error in the definition of current dialect, based on this rule: +- some tags are required, like as, prefixes, suffixes, beginnings and ends. +- some tags must be unique, like as, modifiers, else, break, empty, ... - - {$x.0} +May 9, 2013 - - {$x.1} +- New static method anyToStr, for convert mixed value to string based on this rule: +- string is string +- boolean is "true" or "false" +- number is "number" +- object with __toString() is __toString() +- object without __toString() is array +- array is count() +- Changed the type of unchangeable methods to "final". - - [$name]{$value} [/$name] +May 3, 2013 - - [$x] {$value} * [/$x] = (# [$x] {$value} * [/$x] 1 #) +- The interpretation of date format was improved. - Output: - ---------------- - P +If you need type the char ":" in the format, and this char is the separator between var and format, then type a backslash before ":", like as this: - e +```div +{/2012-01-01 00:30:00 : Y-m-d h\:i\:s/} - 5 +``` - 3 +In the example the value is "2012-01-01 00:30:00 " and the format is "Y-m-d h:i:s". - P e t e r +April 29, 2013 - 5 * 3 * 7 = 105 +- The interpretation of aggregate functions was improved. The next example work now: +index.tpl +```div +{= products: [ + {name: "Banana", price: 10}, + {name: "Potato", price: 20} +] =} -- Fix some issues -- New method div::isSring as a safe is_string(): - - if is a string return true - - if is a object with __toString method return true +{$products.0.price} +{#products.0.price:2#} +{$sum:products-price} +{#sum:products-price:2,#} +{%sum:products-price} +``` -- bugfix of template variables when it use object's methods - Now you can call a object's method with some ways: +Output - Similar to PHP: +```div +10 +10.00 - {= result: ->method(param1, param2, param3) =} +30 +30,00 +2 - One parameter as JSON data: +``` - {= result: ->method({param1: value1, param2: value2}); +April 24, 2013 -- bugfix of loops, prevent a recursion with var '_item' as object inside the same object: +- Performance: work remembered! Now the engine can remember some actions from previous work and increase their speed. +- New feature: the macros. - Product Object - ( - [price] => 0 - [quantity] => 0 - [_item] => Product Object - *RECURSION* - ) +A macro is a restricted PHP code inside the templates to facilitate the complex processing with the advantages of this language. The security is guaranteed. See the next silly example: +index.php +```php + 'Hello world')); + +``` + +index.tpl + +```div + + +{$title} + +``` + +Output + +```div +Hello world + +HELLO WORLD + +``` + +- New feature: the custom sub-parsers + +A sub-parser is a parser implmemented by the programmer. For example: + +index.php + +```php + 'Hello world')); - {= a: (# {$a} + 1 #) =} +``` - {$a} +index.tpl - {= a: (# {$a} + 1 #) =} +```html +{literal} + +{/literal} - 5 +{$title} - 6 +``` - 7 +Ouput +```html + + +``` + +Hello world + +April 17, 2013 + +- bugfix in the bodies of multi-replacements +- Changed the name of method multiReplace by parseMultiReplace + +April 13, 2013 - The template variables's manipulation was improved: - Example: - --------------- +Example: - {= product: { - name: "banana" - price: 20 - } =} +```div +{= product: { + name: "banana" +``` - Name: {^product.name} - Price: ${#product.price:2.#} +price: 20 - {= product.price: (# {$product.price} * 2 #) =} +```div +} =} - Double price: ${#product.price:2.#} +Name: {^product.name} +Price: ${#product.price:2.#} - [[product - Current price: {$price} - product]] +{= product.price: (# {$product.price} * 2 #) =} - Output: - ---------------- +Double price: ${#product.price:2.#} - Name: banana - Price: $20.00 +[[product +Current price: {$price} +``` - Double price: $40.00 +product]] - Current price: 40 +Output: -- New static methods are added: +```div +Name: banana +Price: $20.00 - div::issetVar($var, $items) - div::unsetVar($var, $items) - div::setVarValue($var, $value, $items) - div::getVarValue($var, $items) - div::getVars($items) +Double price: $40.00 - Example: - --------------- - product - [1] => product.name - [2] => product.price - ) +$data = array(); -- The method setItem and getItem was improved with detection of complex variable's names: +div::setVarValue("product.name", "Banana", $data); +div::setVarValue("product.price", 10, $data); +div::setVarValue("product.amount", 0, $data); - Example: - ---------------------- +if (div::issetVar("product.name", $data)){ + echo div::getVarValue("product.name", $data); +} - array( - "name" => "Banana", - "price" => null - ) - )); +print_r(div::getVars($data)); - $tpl->setItem("product.price", 10); +``` - index.tpl - ------------------- - Name: {$product.name} - Price: ${#product.price:2.#} +Output: - Output - ------------------ - Name: Banana - Price: $10.00 +```div +Banana +Amount not specified +Array +( + [0] => product + [1] => product.name + [2] => product.price +) +``` -- bugfix in the bodies of multi-replacements -- Changed the name of method multiReplace by parseMultiReplace +- The method setItem and getItem was improved with detection of complex variable's names: +Example: +```php + array( +"name" => "Banana", +"price" => null +) +)); - index.php - ---------- - setItem("product.price", 10); - include 'div.php'; +``` - echo new div('index.tpl', array('title' => 'Hello world')); +index.tpl - index.tpl - ------------- - +Name: {$product.name} Price: ${#product.price:2.#} - {$title} +Output - Output - ----------- - Hello world +```div +Name: Banana +Price: $10.00 - HELLO WORLD +``` -- New feature: the custom sub-parsers +April 12, 2013 - A sub-parser is a parser implmemented by the programmer. For example: +- The order respect of template variables's manipulation was improved: - index.php - -------------- - 'Hello world')); +{$a} - index.tpl - ---------------- +{= a: (# {$a} + 1 #) =} - {literal} - - {/literal} +Output: - {$title} +```div +5 - Ouput - ---------------- - +``` - Hello world +April 11, 2013 +- bugfix of template variables when it use object's methods Now you can call a object's method with some ways: +Similar to PHP: +```div +{= result: ->method(param1, param2, param3) =} -- The interpretation of aggregate functions was improved. - The next example work now: +``` - index.tpl - ------------ - {= products: [ - {name: "Banana", price: 10}, - {name: "Potato", price: 20} - ] =} +One parameter as JSON data: - {$products.0.price} - {#products.0.price:2#} +```div +{= result: ->method({param1: value1, param2: value2}); - {$sum:products-price} - {#sum:products-price:2,#} - {%sum:products-price} +``` - Output - ------------- - 10 - 10.00 +- bugfix of loops, prevent a recursion with var '_item' as object inside the same object: - 30 - 30,00 - 2 +Product Object +```div +( + [price] => 0 + [quantity] => 0 + [_item] => Product Object +``` +*RECURSION* -- The interpretation of date format was improved. +```div +) - If you need type the char ":" in the format, and this - char is the separator between var and format, then type - a backslash before ":", like as this: +``` - {/2012-01-01 00:30:00 : Y-m-d h\:i\:s/} +April 07, 2013 - In the example the value is "2012-01-01 00:30:00 " and - the format is "Y-m-d h:i:s". +- Fix some issues +- New method div::isSring as a safe is_string(): +- if is a string return true +- if is a object with __toString method return true +April 04, 2013 +- The scalar values as a complex values! What? -- New static method anyToStr, for convert mixed value to string based on this rule: - - string is string - - boolean is "true" or "false" - - number is "number" - - object with __toString() is __toString() - - object without __toString() is array - - array is count() -- Changed the type of unchangeable methods to "final". +Yes! Now all the scalar values can be used as strings. Then, the strings can be used like complex values, that is to say, as group of characters. For example: +index.tpl +```div + {= name: "Peter" =} + + + {$name.0} + + + {$name.1} + + {= x: 537 =} + + + {$x.0} + + + {$x.1} + + + [$name]{$value} [/$name] + + + [$x] {$value} * [/$x] = (# [$x] {$value} * [/$x] 1 #) + +``` -- Enable custom dialect for developers! +Output: - A dialect is defined by the group of constant whose name - begins with DIV_TAG. This dialect is subject to some simple - rules that Div forces to complete for preveer inconsistencies and - infinite loops. +```div +P -- New static method isValidCurrentDialect, for detect error in the - definition of current dialect, based on this rule: - - some tags are required, like as, prefixes, suffixes, beginnings and ends. - - some tags must be unique, like as, modifiers, else, break, empty, ... +e +5 +3 -- Created a tool to build dialects. -- Release the 3.9 version +P e t e r +5 * 3 * 7 = 105 +``` ## Commits + - No commits found. diff --git a/releases/v4.0.0.md b/releases/v4.0.0.md index c892225..068f6e3 100644 --- a/releases/v4.0.0.md +++ b/releases/v4.0.0.md @@ -1,137 +1,180 @@ # Release v4.0.0 + Date: 2013-05-27 ## Description +May 27, 2013 + +- Change to private some div's properties +- Release 4.0 version + +May 25, 2013 + +- Improvement of the conditional parts detection + +May 24, 2013 + - Fixed some bugs in locations and conditional parts. - Created a translator of dialects. Now div have 2 new public methods: - $tpl = new div('templateWithDialectX.tpl', $data); +```div +$tpl = new div('templateWithDialectX.tpl', $data); + +$dialectY = 'json code'; // or associative array + +// Return the translated template +$new_code = $tpl->translateFrom($dialectY); + +// Translate and change the original template +$tpl->translateAndChange($dialectY); + +``` + +- New feature: template properties. Now you can specify some properties in the template's code, for example, the dialect of the current template: + +Example: + +index.tpl + +```div +@_DIALECT = smarty.dialect + +{* this is a comment *} +Name: {$name} + +{literal} +{$name} +{/literal} + +{% other %} - $dialectY = 'json code'; // or associative array +``` - // Return the translated template - $new_code = $tpl->translateFrom($dialectY); +other.tpl - // Translate and change the original template - $tpl->translateAndChange($dialectY); +```div +@_DIALECT = twig.dialect -- New feature: template properties. Now you can specify some properties -in the template's code, for example, the dialect of the current template: +{{ foo.bar }} - Example: +``` - index.tpl - -- - @_DIALECT = smarty.dialect +smarty.dialect - {* this is a comment *} - Name: {$name} +```div +{ + 'DIV_TAG_IGNORE_BEGIN': '{literal}', + 'DIV_TAG_IGNORE_END': '{/literal}', +``` - {literal} - {$name} - {/literal} +'DIV_TAG_COMMENT_BEGIN': '{*', 'DIV_TAG_COMMENT_END': '*}' - {% other %} +```div +} - other.tpl - -- - @_DIALECT = twig.dialect +``` - {{ foo.bar }} +twig.dialect - smarty.dialect - -- - { - 'DIV_TAG_IGNORE_BEGIN': '{literal}', - 'DIV_TAG_IGNORE_END': '{/literal}', - 'DIV_TAG_COMMENT_BEGIN': '{*', - 'DIV_TAG_COMMENT_END': '*}' - } +```div +{ +``` - twig.dialect - --- - { - 'DIV_TAG_REPLACEMENT_SUFFIX': ' }}', - 'DIV_TAG_MODIFIER_SIMPLE': '{ ' - } +'DIV_TAG_REPLACEMENT_SUFFIX': ' }}', 'DIV_TAG_MODIFIER_SIMPLE': '{ ' - index.php - --- - 'Peter', - 'foo' => array( - 'bar' => 45 - ) - )); +``` - Output - --- - Name: Peter +index.php - {$name} +```php + 'Peter', +'foo' => array( +'bar' => 45 +) +)); + +``` + +Output + +```div +Name: Peter + +{$name} + +45 +``` - 45 - New feature: predefined subparsers. Div provide pre-defined sub-parsers, for example, - {parse}...{/parse}. This example of sub-parser make a pre-proccess of enclosed code. - This means that a new instance of div will be created, similar to the loops - and the capsules. Other predefined subparsers will be developed in future releases. - -- New feature: sub-parser's events. Now in the templates's code you can specify when - a sub-parser will be executed: beforeParse, afterInclude or afterParse. Example: - - index.tpl - --------------------------- - {= name: "Peter" =} - {= products: [ - { - name: "banana", - price: 40 - }, - { - name: "potato", - price: 25 - } - ] =} - - [$products] - {parse:beforeParse} - Name: {$name} - {/parse:beforeParse} - - Product name: {$name} - - {% other %} - [/$products] - - other.tpl - --------------------------- - {parse:beforeParse} - Other name: {$name} - {/parse:beforeParse} - Output - ---------- - Name: Peter - Product name: banana - Other name: banana - Name: Peter - Product name: potato - Other name: potato +```div +{parse}...{/parse}. This example of sub-parser make a pre-proccess of enclosed code. +``` +This means that a new instance of div will be created, similar to the loops and the capsules. Other predefined subparsers will be developed in future releases. +- New feature: sub-parser's events. Now in the templates's code you can specify when a sub-parser will be executed: beforeParse, afterInclude or afterParse. Example: -- Improvement of the conditional parts detection +index.tpl +```div + {= name: "Peter" =} +{= products: [ + { + name: "banana", +``` +price: 40 -- Change to private some div's properties -- Release 4.0 version +```div +}, +{ + name: "potato", +``` +price: 25 +```div + } +] =} + +[$products] + {parse:beforeParse} + Name: {$name} + {/parse:beforeParse} + + Product name: {$name} + + {% other %} +[/$products] + +``` + +other.tpl + +```div + {parse:beforeParse} + Other name: {$name} +{/parse:beforeParse} + +``` + +Output + +```div +Name: Peter +``` + +Product name: banana Other name: banana Name: Peter Product name: potato Other name: potato ## Commits + - No commits found. diff --git a/releases/v4.1.0.md b/releases/v4.1.0.md index 5e8cafd..26fdde5 100644 --- a/releases/v4.1.0.md +++ b/releases/v4.1.0.md @@ -1,19 +1,21 @@ # Release v4.1.0 + Date: 2013-05-30 ## Description -- Fix and improve the algorithm of div::getVarValue() method. -- Fix the detection of conditional parts. - - +May 30, 2013 - Test new version - Minor bugs was fixed - Improvement of the detection of date formats - Release 4.1 version +May 29, 2013 +- Fix and improve the algorithm of div::getVarValue() method. +- Fix the detection of conditional parts. ## Commits + - No commits found. diff --git a/releases/v4.2.0.md b/releases/v4.2.0.md index df72e40..b626800 100644 --- a/releases/v4.2.0.md +++ b/releases/v4.2.0.md @@ -1,91 +1,113 @@ # Release v4.2.0 + Date: 2013-06-08 ## Description -- Improvement of the algorithm of getRanges() to make all the possible one. Now -Div continues searching ranges after unclosed tags. - - - For next template: - - index.tpl - ---------- - {/ - {/div.now/} +June 08, 2013 - - In previous versions (1.0 - 4.1): - - Output: - ---------- - {/ - {/div.now/} - - - From Div 4.2: +- Improvement of template's documentation +- Release new version 1.1 of Div Dialect Creator +- Release the version 4.2 - Output: - ---------- - {/ - 2013-05-31 +June 02, 2013 +- Fix/improve the translator +- Fix/improve the parser +June 01, 2013 - Improvement of the parser of ignored parts - Improvement of the parser of includes -- New feature: template's documentation. Now in the comments you can -document the template. The documentation's parts have @ as prefix. For example: - - - - To obtain the documentation data: - - $data = div::getDocs(); - - To obtain a readable documentation: - - echo div::getDocsReadable(/* optional template */); +- New feature: template's documentation. Now in the comments you can document the template. The documentation's parts have @ as prefix. For example: + +```html + + +``` + +To obtain the documentation data: + +```div +$data = div::getDocs(); + +``` + +To obtain a readable documentation: + +```div +echo div::getDocsReadable(/* optional template */); + +``` - Fix the algorithm of getRanges(). - Fix the parser of macros. - Added a new sub-parser's event: afterReplace. +May 31, 2013 -- Fix/improve the translator -- Fix/improve the parser +- Improvement of the algorithm of getRanges() to make all the possible one. Now Div continues searching ranges after unclosed tags. +- For next template: +index.tpl -- Improvement of template's documentation -- Release new version 1.1 of Div Dialect Creator -- Release the version 4.2 +```div +{/ +{/div.now/} + +``` + +- In previous versions (1.0 - 4.1): + +Output: +```div +{/ +{/div.now/} +``` + +- From Div 4.2: + +Output: + +```div +{/ +``` + +2013-05-31 ## Commits + - No commits found. diff --git a/releases/v4.3.0.md b/releases/v4.3.0.md index f44c846..51f9fa2 100644 --- a/releases/v4.3.0.md +++ b/releases/v4.3.0.md @@ -1,167 +1,211 @@ # Release v4.3.0 + Date: 2013-06-15 ## Description -- Improvement of the parser of template's vars: - If the value is not valid JSON, it will be considered as - a template and will be parsed before decoding. +June 15, 2013 + +- Improvement of logs's system +- Release 4.3 version + +June 13, 2013 + +- Integration with Google Chrome/Console and Mozilla Firefox/Firebug plugins. Now the engine's messages will be appear in this browsers's features. + +- Improvement of detection of infinite loops in recursive replacements: + +index.tpl + +```div +{= bar: {${$e}} =} +{= e: 'bar'} =} + +{$bar} + +``` + +Output + +```div +[[ FATAL ERROR ]] WAS DETECTED AN INFINITE LOOP IN RECURSIVE REPLACEMENT OF $foo. + +``` + +- Improvement of parser and bugs fixes: if foo not existed, widget waits forever. Now the next example works: + +index.tpl + +```div + {= widget: 45 =} + +{?( "{$foo}" == "a" )?} + {= bar: 5 =} +{/?} - See the next sequence: +{$widget} - 1. Value is not valid JSON: {= digits: [[:0,8:]{$value},[/]9] =} - 2. Value was parsed: {= digits: [0,1,2,3,4,5,6,7,8,9] =} - 3. Now "digits" is an array. - 4. Replacement: {$digits} +``` - See the difference: +Output - 1. Value is valid JSON: {= digits: "[[:0,8:]{$value},[/]9]" =} - 2. Value was not parsed: {= digits: "[[:0,8:]{$value},[/]9]" =} - 3. Now "digits" is an string. - 4. Replacement: {$digits} +```div +45 -- Improvement of the parser of template's variables. Was improved - the detection of assignment of variables in any part of the - JSONs values. For example: +Solved! - index.tpl - --------- +``` - {= cities: ["New York", "Tokyo"] =} +June 12, 2013 - {= combobox: { - id: "cboCities", - options: $cities - } =} +- Improvement of relative include/preprocessed templates. Now the next example works: - {$combobox.options.0} +index.tpl - Output - --------- - New York +```div +{% folder/tpl1 %} +``` +/folder/tpl1.tpl -- Improvement of relative include/preprocessed templates. - Now the next example works: +```div +{% folder2/tpl2 %} - index.tpl - ------------------------- - {% folder/tpl1 %} +``` - /folder/tpl1.tpl - ------------------------- - {% folder2/tpl2 %} +/folder1/folder2/tpl2.tpl - /folder1/folder2/tpl2.tpl - ------------------------- - {% tpl3 %} +```div +{% tpl3 %} - /folder1/folder2/tpl3.tpl - ------------------------- - Hello +``` - Ouput - ------------------------- - Hello +/folder1/folder2/tpl3.tpl -- Improvement of template's variables assignment. - Now the next example works: +Hello - index.tpl - ------------------------- - {= position: "absolute" =} +Ouput - {?( "{$position}" == "absolute" )?} - {= absolute: true =} - @else@ - {= absolute: false =} - {/?} +Hello - ?$absolute YES $absolute? +- Improvement of template's variables assignment. Now the next example works: - Ouput - ------------------------- - YES +index.tpl + +```div +{= position: "absolute" =} + +{?( "{$position}" == "absolute" )?} + {= absolute: true =} +@else@ + {= absolute: false =} +{/?} + +?$absolute YES $absolute? + +``` + +Ouput + +YES - Improvement of the variables's scope: - Now the next example works: - index.tpl - ---------------- - {= foo: true =} - {= bar: [1,2,3] =} +Now the next example works: - ?$foo - YES - $foo? +index.tpl - [$bar] - {= foo: (# {$value} > 1 #) =} - ?$foo - YES - @else@ - NO - $foo? - [/$bar] +```div +{= foo: true =} +{= bar: [1,2,3] =} - {$foo} +?$foo +``` - Output - -------------- - YES +YES - NO +```div +$foo? - YES +[$bar] + {= foo: (# {$value} > 1 #) =} + ?$foo +``` - YES +YES - true +```div +@else@ +``` +NO -- Integration with Google Chrome/Console and Mozilla Firefox/Firebug plugins. - Now the engine's messages will be appear in this browsers's features. +```div + $foo? +[/$bar] -- Improvement of detection of infinite loops in recursive replacements: +{$foo} - index.tpl - ------------- - {= bar: {${$e}} =} - {= e: 'bar'} =} +``` - {$bar} +Output - Output - ------------- - [[ FATAL ERROR ]] WAS DETECTED AN INFINITE LOOP IN RECURSIVE REPLACEMENT OF $foo. +```div +YES -- Improvement of parser and bugs fixes: if foo not existed, widget waits forever. - Now the next example works: +NO - index.tpl - ------------------ - {= widget: 45 =} +YES - {?( "{$foo}" == "a" )?} - {= bar: 5 =} - {/?} +YES + +true - {$widget} +``` - Output - ------------------ - 45 +June 10, 2013 - Solved! +- Improvement of the parser of template's vars: +If the value is not valid JSON, it will be considered as a template and will be parsed before decoding. +See the next sequence: -- Improvement of logs's system -- Release 4.3 version +1. Value is not valid JSON: {= digits: [[:0,8:]{$value},[/]9] =} +2. Value was parsed: {= digits: [0,1,2,3,4,5,6,7,8,9] =} +3. Now "digits" is an array. +4. Replacement: {$digits} +See the difference: +1. Value is valid JSON: {= digits: "[[:0,8:]{$value},[/]9]" =} +2. Value was not parsed: {= digits: "[[:0,8:]{$value},[/]9]" =} +3. Now "digits" is an string. +4. Replacement: {$digits} + +- Improvement of the parser of template's variables. Was improved the detection of assignment of variables in any part of the JSONs values. For example: + +index.tpl + +```div +{= cities: ["New York", "Tokyo"] =} + +{= combobox: { + id: "cboCities", + options: $cities +} =} + +{$combobox.options.0} + +``` + +Output + +```div +New York +``` ## Commits + - No commits found. diff --git a/releases/v4.4.0.md b/releases/v4.4.0.md index 4ed6d34..e477a16 100644 --- a/releases/v4.4.0.md +++ b/releases/v4.4.0.md @@ -1,22 +1,24 @@ # Release v4.4.0 + Date: 2013-07-27 ## Description -- Improvement of the modifier "escape single quotes" (\') - to "escape single/double quotes" (\"). -- Improvement of default documentation's template. +July 27, 2013 +- bugfixs! +- Release 4.4 version +July 19, 2013 - bugfix the translator - New feature: Multi template sources (based on include_path PHP setting) +June 15, 2013 -- bugfixs! -- Release 4.4 version - - +- Improvement of the modifier "escape single quotes" (\') to "escape single/double quotes" (\"). +- Improvement of default documentation's template. ## Commits + - No commits found. diff --git a/releases/v4.5.0.md b/releases/v4.5.0.md index 286b3f9..29fe2f4 100644 --- a/releases/v4.5.0.md +++ b/releases/v4.5.0.md @@ -1,284 +1,354 @@ # Release v4.5.0 + Date: 2014-12-01 ## Description -- Decrease of priority in parser's specialchars +December 1, 2014 +- some bug fixes +- Release 4.5 version +November 24, 2014 -- An important bug was fixed: the memory in the loops: +- improve `div::isValidPHPCode()` - In div 4.4 dont't work: +October 7, 2014 - index.php - ---- - array("Havana", "Tokyo"))); +October 6, 2014 - index.tpl - ---- - {= foo: [ - { title: "Cities", - content: '{% cities.tpl %}' - } - ] =} +- new setup var: `div.clear_locations` (= true by default). This means that the locations will be clear or not at the end (parse_level = 0). Then, the component are more flexible with **pre-processed templates**: - {% layout.tpl %} +comp.tpl - layout.tpl - ----- - ?$foo - [$foo] -

              {$title}

              - {$content}
              - [/$foo] - $foo? +```html +(( before )) (( after )) +``` - cities.tpl - ----- - ?$cities - [$cities] - {$value} - [/$cities] - @else@ - No cities - $cities? +index.tpl - Output (wrong!) - ----- -

              Cities

              - No cities
              +```html +{%% comp: { +type: "text", +name: "first_name", +div: { +clear_locations: false +} +} %%} - Output (great in 4.5) - ----- -

              Cities

              - Havana Tokio
              + +{{before before}} +{{after after}} +``` +September 26, 2014 -- bugfix: div::getFileContents() +- bugfix `parseData()` vs `parseMatch()` logical order +September 23, 2014 +- bug fix in `parsePreprocessed()` when $pdata is null +- bug fix with number formats inside loops -- Improvement of global design vars in loops and capsules +September 21, 2014 +- new feature: advanced options/params for includes +index.tpl -- bugfix: div::fileExists and wrong include paths calculation +```div +{% subtpl: { +from: "", +to: "", +offset: 2, +limit: 1 +} %} +``` +subtpl.tpl +```div +Any text... -- Memory fixed! +Some text 1 +Any text... +Some text 2 -- Some bugfixs -- Add new important security feature: setup literals items/vars, for prevent injections! +Any text +``` + +- bugfix: Preparing allowed methods before execute the macros + +September 20, 2014 + +- bugfix: Parsing macros inside preprocessed templates. New argument $min_level for parse() method. +- Add new allowed functions in macros, formulas and expressions: `array_keys` `get_object_vars` `is_object` +- new static method `div::div():` + +index.php + +```php + "value1")); +``` + +- Allow T_BREAK token in macros for foreach and other loops. Then, the follow macro is an error: + +index.tpl + +```php + +``` + +Output + +```shell +Fatal error: Cannot break/continue 1 level in div.php: eval()'d code on line 1 +``` + +September 17, 2014 + +- bugfix/improve - Parsing orphan's parts while checksum not change. Do it because the orphans's parts stop the parser and the results are ugly. + +September 16, 2014 + +- big fix: Set the priority to inline data in pre-processed templates above global design vars + +September 11, 2014 + +- bigfix: Save sections of loops and capsules when makeItAgain(); (Div doesn't know the future) + +September 9, 2014 + +- bugfix: Adding items to array in templates + +```div +{= somearray[]: "new item" =} + +``` + +- bugfix: Don't set item var as design var in div::parseData(); + +September 8, 2014 + +- bugfix: Parse pre-processed templates with all items/vars (Div doesn't know the future) + +August 28, 2014 + +- New feature for preprocessed templates: specific data + +Syntax: + +```div +{%% tpl_file: data %%} + +``` + +data is: json, name of var or filename with json Example: +Now is more simple for build the components: + index.tpl ---------------- -{= div.literals: ["text1", "text2"] =} -{$text1} +```div +{%% form: { + action: "login.php", + method: "post.php", + fields: [ + { + type: "text", + name: "user", + label: "User" + },{ + type: "password", + name: "pass", + label: "Password" + } + ], + submit: { + value: "login", + name: "btnLogin" + } +} %%} -{$text2} +``` -{$text3} +form.tpl -index.php ---------------- -echo new div('index.tpl', array( - 'text1' => '{/ignore}[:1,5:] {$value} [/]{ignore}', // I am being about deceiving the security - 'text2' => '[:1,100;] text to repeat [/]', - 'text3' => '[:1,3;] some [/]' -)); +```html +
              + [$fields] + {$label}:
              +
              + [/$fields] + +
              + -output ---------------- -[:1,5;] {$value} [/] -[:1,100;] text to repeat [/] -some some some +``` +August 17, 2014 +- Security fix: prevent obtrusive code in method calls. Now next code dont work: + +```div +{= content: ->getPage(file_put_contents('some.txt','some text')) =} + +``` + +August 5, 2014 + +- Fix the memory in the loops + +August 4, 2014 + +- Fix macros parsing when a previous template var never match + +August 2, 2014 - Allow is_array PHP function in macros - New method for add literal vars in PHP: div::addLiteral(); +June 30, 2014 +- Some bugfixs +- Add new important security feature: setup literals items/vars, for prevent injections! -- Fix macros parsing when a previous template var never match +Example: +index.tpl +```div +{= div.literals: ["text1", "text2"] =} -- Fix the memory in the loops +{$text1} +{$text2} +{$text3} -- Security fix: prevent obtrusive code in method calls. Now next code dont work: +``` -{= content: ->getPage(file_put_contents('some.txt','some text')) =} +index.php +echo new div('index.tpl', array( 'text1' => '{/ignore}[:1,5:] {$value} [/]{ignore}', // I am being about deceiving the security 'text2' => '[:1,100;] text to repeat [/]', 'text3' => '[:1,3;] some [/]' +```div +)); -- New feature for preprocessed templates: specific data +``` - Syntax: - - {%% tpl_file: data %%} - - data is: json, name of var or filename with json - - Example: - - Now is more simple for build the components: - - index.tpl - ------------ - {%% form: { - action: "login.php", - method: "post.php", - fields: [ - { - type: "text", - name: "user", - label: "User" - },{ - type: "password", - name: "pass", - label: "Password" - } - ], - submit: { - value: "login", - name: "btnLogin" - } - } %%} - - form.tpl - ------------ -
              - [$fields] - {$label}:
              -
              - [/$fields] - -
              +output +```div +[:1,5;] {$value} [/] +[:1,100;] text to repeat [/] +``` +some some some -- bugfix: Parse pre-processed templates with all items/vars (Div doesn't know the future) +February 05, 2014 +- Memory fixed! +December 25, 2013 -- bugfix: Adding items to array in templates +- bugfix: div::fileExists and wrong include paths calculation -{= somearray[]: "new item" =} +December 5, 2013 -- bugfix: Don't set item var as design var in div::parseData(); +- Improvement of global design vars in loops and capsules +December 4, 2013 +- bugfix: div::getFileContents() -- bigfix: Save sections of loops and capsules when makeItAgain(); (Div doesn't know the future) +August 30, 2013 +- An important bug was fixed: the memory in the loops: -- big fix: Set the priority to inline data in pre-processed templates above global design vars ---- -- bugfix/improve - Parsing orphan's parts while checksum not change. Do it because the orphans's parts stop the parser and the results are ugly. ---- -- bugfix: Parsing macros inside preprocessed templates. New argument $min_level for parse() method. -- Add new allowed functions in macros, formulas and expressions: `array_keys` `get_object_vars` `is_object` -- new static method `div::div():` +In div 4.4 dont't work: index.php ```php "value1")); + +include "div.php"; +echo new div("test.tpl", array("cities" => array("Havana", "Tokyo"))); + ``` -- Allow T_BREAK token in macros for foreach and other loops. Then, the follow macro is an error: index.tpl -```php - -``` +```div +{= foo: [ + { title: "Cities", + content: '{% cities.tpl %}' + } +] =} -Output -```shell -Fatal error: Cannot break/continue 1 level in div.php: eval()'d code on line 1 -``` ---- -- new feature: advanced options/params for includes +{% layout.tpl %} -index.tpl -``` -{% subtpl: { - from: "", - to: "", - offset: 2, - limit: 1 -} %} ``` -subtpl.tpl +layout.tpl + +```html +?$foo + [$foo] +

              {$title}

              + {$content}
              + [/$foo] +$foo? ``` -Any text... -Some text 1 +cities.tpl -Any text... +```div +?$cities + [$cities] + {$value} + [/$cities] +@else@ +``` -Some text 2 +No cities + +```div +$cities? -Any text ``` -- bugfix: Preparing allowed methods before execute the macros ---- -- bug fix in `parsePreprocessed()` when $pdata is null -- bug fix with number formats inside loops ---- -- bugfix `parseData()` vs `parseMatch()` logical order ---- -- new setup var: `div.clear_locations` (= true by default). This means that the locations will be clear or not at the end (parse_level = 0). Then, the component are more flexible with **pre-processed templates**: - -comp.tpl +Output (wrong!) ```html -(( before )) (( after )) +

              Cities

              ``` -index.tpl -```html -{%% comp: { - type: "text", - name: "first_name", - div: { - clear_locations: false - } -} %%} +No cities
              - +Output (great in 4.5) -{{before before}} -{{after after}} +```html +

              Cities

              ``` ---- -- improve performance changing $vars with `__temp['vars']` var in `parseMacros();` because because `get_defined_vars` return also `vars` -- prevent infinite loops in `div::cop();` ---- -- improve `div::isValidPHPCode()` ---- -- some bug fixes -- Release 4.5 version ---- +Havana Tokio
              + +July 29, 2013 + +- Decrease of priority in parser's specialchars ## Commits + - No commits found. diff --git a/releases/v4.6.0.md b/releases/v4.6.0.md index 9b8e027..a7de940 100644 --- a/releases/v4.6.0.md +++ b/releases/v4.6.0.md @@ -1,10 +1,14 @@ # Release v4.6.0 + Date: 2015-12-11 ## Description + +December 11, 2015 + - Bugfix in div class constructor - Release 4.6 version ---- ## Commits + - No commits found. diff --git a/releases/v4.7.0.md b/releases/v4.7.0.md index c30986a..ddfdb0d 100644 --- a/releases/v4.7.0.md +++ b/releases/v4.7.0.md @@ -1,7 +1,16 @@ # Release v4.7.0 + Date: 2015-12-19 ## Description + +December 19, 2015 + +- several tests +- Release 4.7 version + +December 12, 2015 + - [starting release 4.7] - some bug fixes, thanks to `gracix` and `Takefumi Ota` - Improve template's vars and OOP: now you can access to a public method of any object. @@ -14,11 +23,11 @@ index.php first_name.' '.$this->last_name; - } - ... + ... + public function getFullName(){ + return $this->first_name.' '.$this->last_name; + } + ... } echo new div('index.tpl', array("person" => new Person(...))); @@ -26,14 +35,11 @@ echo new div('index.tpl', array("person" => new Person(...))); index.tpl -``` +```div {= fullname: ->person.getFullName() =}` The full name is {$fullname} ``` ---- -- several tests -- Release 4.7 version - ## Commits + - No commits found. diff --git a/releases/v4.8.0.md b/releases/v4.8.0.md index bbc8f04..e46b84d 100644 --- a/releases/v4.8.0.md +++ b/releases/v4.8.0.md @@ -1,52 +1,64 @@ # Release v4.8.0 + Date: 2016-10-10 ## Description + +October 10, 2016 + +- Several tests +- Release 4.8 version + +January 12, 2016 + +- review example + +December 24, 2015 + +- improved dialect translator `div::translateFrom` +- some bug fixes +- update documentation + +December 23, 2015 + - add new feature for dialects: DIV_TAG_VAR_MEMBER_DELIMITER. This dialect's constant define a delimiter for variable's members. For example: by default you use: -``` + +```div {$person.name} ``` but now you can do... index.php + ```php '); +define('DIV_TAG_VAR_MEMBER_DELIMITER','->'); - include "div.php"; +include "div.php"; - echo new div("index.tpl", array( - 'person' => array( - 'name' => 'Peter', - 'child' => array( - 'name' => 'eli' - ) - ) - )); +echo new div("index.tpl", array( +'person' => array( +'name' => 'Peter', +'child' => array( +'name' => 'eli' +) +) +)); ``` + index.tpl -``` + +```div {$person->child->name} -{$person->name} +{$person->name} ``` -TODO: improve dialect creator tool -TODO: check dialect translator method div::translateFrom() - - -- improved dialect translator `div::translateFrom` -- some bug fixes -- update documentation ---- -- review example ---- -- Several tests -- Release 4.8 version ---- +TODO: improve dialect creator tool TODO: check dialect translator method div::translateFrom() ## Commits + - No commits found. diff --git a/releases/v4.9.0.md b/releases/v4.9.0.md index 0684000..2331b97 100644 --- a/releases/v4.9.0.md +++ b/releases/v4.9.0.md @@ -1,16 +1,42 @@ # Release v4.9.0 + Date: 2016-12-22 ## Description + +December 22, 2016 + +- PHP 7 Compatibility check +- Release 4.9 version + +November 16, 2016 + +- important bugfix/improvement: access to parent loop + +```div +[$parentloop] parent => +[$childloop] child => +Parent key: {$parent._key} +Child key: {$_key} or {$child._key} +[/$childloop] +[/$parentloop] +``` + +- TODO: test & release + +November 14, 2016 + - add new default subparser join Syntax: -``` + +```div {join} varname | delimiter {/join} ``` index.tpl -``` + +```div {= tags: ['a','b', 'c'] =} {join} tags |, {/join} {join} tags |,{/join} @@ -18,28 +44,13 @@ index.tpl ``` Output: -``` + +```div a, b, c a,b,c abc ``` ---- -- important bugfix/improvement: access to parent loop - -``` -[$parentloop] parent => - [$childloop] child => - Parent key: {$parent._key} - Child key: {$_key} or {$child._key} - [/$childloop] -[/$parentloop] -``` - -- TODO: test & release - -- PHP 7 Compatibility check -- Release 4.9 version ---- ## Commits + - No commits found. diff --git a/releases/v5.1.0.md b/releases/v5.1.0.md index 04066f1..b95d086 100644 --- a/releases/v5.1.0.md +++ b/releases/v5.1.0.md @@ -1,151 +1,169 @@ # Release v5.1.0 + Date: 2019-07-22 ## Description -- Some bugfixs -- New variable for inline data of preprocessed templates: `div.standalone`, by default is FALSE. - This means that the "foo" variable will not be passed to the template pre-processor. That is, the variables in the parent template will be ignored and only the data specified in the line will be used. -``` -{= foo: value =} -{%% block.tpl: { - div: { - standalone: true - } -} %%} -``` +Jul 22, 2019 + +- `release` version 5.1.0 +- `improvement`: Better resolution of default template for child classes of div, using Reflection! - This better facilitates the recursive inclusion of templates, useful in generation of source code and other hierarchies like XML, HTML, JSON, etc. +**/some/folder/in/the/end/of/the/world/Page.tpl** -- Do not include anything within the conditional blocks if the conditions have not been resolved. This check prevent infinite loops. +```div +Hello people +``` + +**/some/folder/in/the/end/of/the/world/Page.php** ```php - ?$block - {%% block: {...} %%} <-- wait for block question results - $block? +translateFrom($dialectFrom); +```div +{$zoo} +{$foo} ``` - Translate from current dialect to other dialect: +Jul 2, 2019 + +- new feature for custom engine: + +MyComponent.php ```php -$tpl->translateTo($dialectFrom); +MyComponent extends div { + .... +} ``` -Translate from any dialect to any dialect: +index.tpl: -```php -$tpl->translate($dialectFrom, $dialectTo, $src, $items); +```div +{%% component: { +div: { +engine: "MyComponent" +}, +someProperty: "bla" +} %%} ``` -Maybe you need prepare the current dialect first: +Jun 27, 2019 + +- important change!: Now NULLs vars exists and are replaced with empty strings + +PHP ```php -prop = $tpl->getTemplateProperties(); -$tpl->__src = $tpl->prepareDialect(null, $prop); -``` ---- -- Fix dynamic include's paths inside loops -``` -[$blocks] - {% blocks/block-{$id}.tpl %} -[/$blocks] +echo new div('Var is: {$var}', ['var' => null]); ``` ---- -- Fix and improve getAuxiliaryEngine ---- -- Fix a bug with `getAuxiliaryEngine` (clone vs assignment) -- Add some new system vars - - `div.class_name`: the name of current invoked class ('div' or child of 'div') - - `div.super_class_name`: the name of super parent of current invoked class name (normally is 'div') -- Code review ---- -- Change scope of `->loadTemplateProperties()` to public -- Other minor fixes -- Automatic update of template source code after `prepareDialect()` ... -- ... && new param for `->prepareDialect()` for disable automatic update ---- -- Re-thinking the change in **June 10, 2013** about invalid JSON in assignments. Is important the dynamic path of JSON files: -``` -{= i18n: i18n/{$lang}.json =} +OUTPUT before this change: + +```div +Var is: {$var} ``` -`"i18n/{$lang}.json"` without quotes is invalid JSON +OUTPUT after this change: -Then, don't use quotes: -``` -{= i18n: "i18n/{$lang}.json" =} +```div +Var is: ``` -- Important improvement for loading JSON data from relative path in template variable's assignment: +- `important change!`: Fix scope of pre-processed templates inside loops -``` - relative --> - | - v - /app/site/view/i18n/en/messages.json - ^ - | - replacement result +Do not pre-process anything within the loops blocks if the loops have not been resolved The following code did not work as expected, because the pre-process was executed before doing the loop. So the `$col` variable did not exist and logic of the template will be broken. + +```div +[$cols] col => +{%% element: { +tag: "td", +attrs: $col.attrs, +inner: $col.content +} %%} +[/$cols] ``` -/app/site/view/page.tpl +Jun 14, 2019 -``` -{= lang: "en" =} -{= i18n: i18n/{$lang}/messages.json =} +- `bugfix`: better resolution of tags with empty suffix. In this example "list.filter" is a substring of "list.filter.category", and then exists resulting unexpected code if $list.filter is false -{$i18n.message1} -``` +TPL -/app/site/view/i18n/en/messages.json -``` -{ - message1: "Hello" -} +```div +?$list.filter +AAA +?$list.filter.category +BBB +$list.filter.category? +CCC +$list.filter? ``` -Output: +OUTPUT + +```div +?$list.filter +AAA ``` -Hello + +The fix was for other similar situations in div::getBlockRanges(). The stop chars are the same in favor of text plain and XML family: + +```php +$stop_chars = ["<", ">", ' ', "\n", "\r", "\t"]; ``` ---- -- `bugfix` on constructor, when div var is an object and not an array -- Add file_exists as allowed function -- Add in_array as allowed function ---- + +Sep 20, 2018 + - Optimize the code: change "is_null" as "=== null", because is_null is 250ns slower (in favor of PHP 5) In PHP 7 (phpng), is_null is actually marginally faster than `===`, although the performance difference between the two is far smaller. -``` +```div PHP 5.5.9 is_null - float(2.2381200790405) === - float(1.0024659633636) @@ -156,137 +174,163 @@ is_null - float(1.4121870994568) === - float(1.4577329158783) is_null faster by ~5ns per call ``` ---- -- `bugfix`: better resolution of tags with empty suffix. In this example "list.filter" is a substring of "list.filter.category", and then exists resulting unexpected code if $list.filter is false -TPL -``` -?$list.filter - AAA - ?$list.filter.category - BBB - $list.filter.category? - CCC -$list.filter? -``` +Aug 19, 2018 -OUTPUT -``` -?$list.filter - AAA -``` +- `bugfix` on constructor, when div var is an object and not an array +- Add file_exists as allowed function +- Add in_array as allowed function -The fix was for other similar situations in div::getBlockRanges(). -The stop chars are the same in favor of text plain and XML family: +Oct 8, 2017 -```php -$stop_chars = ["<", ">", ' ', "\n", "\r", "\t"]; -``` ---- -- important change!: Now NULLs vars exists and are replaced with empty strings +- Re-thinking the change in **June 10, 2013** about invalid JSON in assignments. Is important the dynamic path of JSON files: -PHP -```php -echo new div('Var is: {$var}', ['var' => null]); +```div +{= i18n: i18n/{$lang}.json =} ``` -OUTPUT before this change: -``` -Var is: {$var} -``` +`"i18n/{$lang}.json"` without quotes is invalid JSON -OUTPUT after this change: +Then, don't use quotes: + +```div +{= i18n: "i18n/{$lang}.json" =} ``` -Var is: + +- Important improvement for loading JSON data from relative path in template variable's assignment: + +```div + relative --> + | + v +/app/site/view/i18n/en/messages.json + ^ + | + replacement result ``` -- `important change!`: Fix scope of pre-processed templates inside loops +/app/site/view/page.tpl -Do not pre-process anything within the loops blocks if the loops have not been resolved -The following code did not work as expected, because the pre-process was executed before doing the loop. So the `$col` variable did not exist and logic of the template will be broken. +```div +{= lang: "en" =} +{= i18n: i18n/{$lang}/messages.json =} +{$i18n.message1} ``` -[$cols] col => - {%% element: { - tag: "td", - attrs: $col.attrs, - inner: $col.content - } %%} -[/$cols] -``` ---- -- new feature for custom engine: -MyComponent.php -```php -MyComponent extends div { - .... +/app/site/view/i18n/en/messages.json + +```div +{ +message1: "Hello" } ``` -index.tpl: -``` -{%% component: { - div: { - engine: "MyComponent" - }, - someProperty: "bla" -} %%} -``` ---- -- Divengine namespace! -- `bugfix`: Fix scope of standalone pre-precessed templates. This fix prevent infinite loops and is util for recursive pre-process in a component based design. +Output: -index.tpl +```div +Hello ``` -{= foo: "bar" =} -{%% component: { - div: {standalone: true}, // ignore parent scope - zoo: "monkey" -} %%} + +Oct 7, 2017 + +- Change scope of `->loadTemplateProperties()` to public +- Other minor fixes +- Automatic update of template source code after `prepareDialect()` ... +- ... && new param for `->prepareDialect()` for disable automatic update + +Sep 30, 2017 [my birthday :)] + +- Fix a bug with `getAuxiliaryEngine` (clone vs assignment) +- Add some new system vars +- `div.class_name`: the name of current invoked class ('div' or child of 'div') +- `div.super_class_name`: the name of super parent of current invoked class name (normally is 'div') +- Code review + +Sep 25, 2017 + +- Fix and improve getAuxiliaryEngine + +Sep 9, 2017 + +- Fix dynamic include's paths inside loops + +```div +[$blocks] +{% blocks/block-{$id}.tpl %} +[/$blocks] ``` -component.tpl +Jun 2, 2017 + +- Improve the translator. Now you can translate from and to other dialects. + +```php +$tpl = new div("index.tpl", []); ``` -{$zoo} -{$foo} + +Translate from other dialect to current dialect: + +```php +$tpl->translateFrom($dialectFrom); ``` ---- -- `bugfix` in div::scanMatch ---- -- `release` version 5.1.0 -- `improvement`: Better resolution of default template for child classes of div, using Reflection! -**/some/folder/in/the/end/of/the/world/Page.tpl** +Translate from current dialect to other dialect: + +```php +$tpl->translateTo($dialectFrom); ``` -Hello people + +Translate from any dialect to any dialect: + +```php +$tpl->translate($dialectFrom, $dialectTo, $src, $items); ``` -**/some/folder/in/the/end/of/the/world/Page.php** +Maybe you need prepare the current dialect first: + ```php -getTemplateProperties(); +$tpl->__src = $tpl->prepareDialect(null, $prop); +``` -use divengine\div; +May 29, 2017 -class Page extends div { +- Some bugfixs +- New variable for inline data of preprocessed templates: `div.standalone`, by default is FALSE. This means that the "foo" variable will not be passed to the template pre-processor. That is, the variables in the parent template will be ignored and only the data specified in the line will be used. +```div +{= foo: value =} +{%% block.tpl: { +div: { +standalone: true } +} %%} ``` -**/index.php** -```php - - {= component.div.standalone: true =} - {%% cmp: component %%} - [/$components] +[$components] component => +{= component.div.standalone: true =} +{%% cmp: component %%} +[/$components] $components? ?$location {$location}}} $location? @@ -29,11 +33,13 @@ $components? ``` __Button.tpl__ -``` + +```html ``` __Page.tpl__ + ```html

              Buttons

              (( top )) @@ -45,43 +51,43 @@ __Page.tpl__ ``` __index.php__ + ```php "welcomePage", - "face" => "{% Page2 %}", - "components" => [ - [ - "face" => "{% Button %}", - "location" => "top", - "caption" => "Click me", - "icon" => '*' - ], - [ - "face" => "{% Button %}", - "location" => "bottom", - "caption" => "Click me again", - "icon" => '#' - ], - [ - "face" => "
                (( items ))
              ", - "location" => "fruits", - "components" => array_map(function ($caption) { - return [ - "face" => "
            1. {$caption}
            2. ", // or "
            3. {\$caption}
            4. " :D - "location" => "items" - ]; - }, ["Banana", "Apple", "Orange"]) - - ] + "id" => "welcomePage", + "face" => "{% Page2 %}", + "components" => [ + [ + "face" => "{% Button %}", + "location" => "top", + "caption" => "Click me", + "icon" => '*' + ], + [ + "face" => "{% Button %}", + "location" => "bottom", + "caption" => "Click me again", + "icon" => '#' + ], + [ + "face" => "
                (( items ))
              ", + "location" => "fruits", + "components" => array_map(function ($caption) { + return [ + "face" => "
            5. {$caption}
            6. ", // or "
            7. {\$caption}
            8. " :D + "location" => "items" + ]; + }, ["Banana", "Apple", "Orange"]) + ] ] -); +]); ``` - --- ## Commits + - No commits found. diff --git a/releases/v5.1.3.md b/releases/v5.1.3.md index 484e546..b2cbdf8 100644 --- a/releases/v5.1.3.md +++ b/releases/v5.1.3.md @@ -1,11 +1,15 @@ # Release v5.1.3 + Date: 2019-08-22 ## Description + +Ago 22, 2019 + - `release` version 5.1.3 - `fix` resolution of templates path for win and *nix OS - `fix` the relative path of included templates inside loop ---- ## Commits + - No commits found. diff --git a/releases/v5.1.4.md b/releases/v5.1.4.md index 434a746..48acc6a 100644 --- a/releases/v5.1.4.md +++ b/releases/v5.1.4.md @@ -1,10 +1,14 @@ # Release v5.1.4 + Date: 2019-08-23 ## Description + +Ago 23, 2019 + - `release` version 5.1.4 - new method div::getVersion() ---- ## Commits + - No commits found. diff --git a/releases/v5.1.5.md b/releases/v5.1.5.md index 52ec09e..9814b99 100644 --- a/releases/v5.1.5.md +++ b/releases/v5.1.5.md @@ -1,10 +1,14 @@ # Release v5.1.5 + Date: 2019-09-21 ## Description + +Sep 21, 2019 + - `release` version 5.1.5 - `fix` div::varExists() method ---- ## Commits + - No commits found. diff --git a/releases/v5.1.6.md b/releases/v5.1.6.md index 381687c..343df2c 100644 --- a/releases/v5.1.6.md +++ b/releases/v5.1.6.md @@ -1,10 +1,14 @@ # Release v5.1.6 + Date: 2020-02-11 ## Description + +Feb 11, 2020 + - `minor fix`: Array and string offset access syntax with curly braces is deprecated - `release` version 5.1.6 ---- ## Commits + - No commits found. diff --git a/releases/v6.0.0.md b/releases/v6.0.0.md index d1d7a92..ff8bb49 100644 --- a/releases/v6.0.0.md +++ b/releases/v6.0.0.md @@ -1,8 +1,11 @@ # Release v6.0.0 + Date: 2023-12-24 ## Description + - Moving forward to PHP 8.x && phpstan checks level 3 ## Commits + - No commits found. diff --git a/releases/v6.0.1.md b/releases/v6.0.1.md index 65fe90f..71f3bd1 100644 --- a/releases/v6.0.1.md +++ b/releases/v6.0.1.md @@ -1,9 +1,12 @@ # Release v6.0.1 + Date: 2024-01-26 ## Description + - Improvements to `div::cop` with Reflection and strict modes - Unit tests ## Commits + - No commits found. diff --git a/releases/v6.1.0.md b/releases/v6.1.0.md index dad3289..0eb9276 100644 --- a/releases/v6.1.0.md +++ b/releases/v6.1.0.md @@ -1,8 +1,11 @@ # Release v6.1.0 + Date: 2024-08-06 ## Description + This release integrates `divengine\\functions`, adds short-circuit constant definitions, passes PHPStan level 3, includes more unit tests, and delivers minor refactorings. ## Commits + - No commits found. diff --git a/releases/v6.1.1.md b/releases/v6.1.1.md index 147530a..2220a03 100644 --- a/releases/v6.1.1.md +++ b/releases/v6.1.1.md @@ -1,8 +1,11 @@ # Release v6.1.1 + Date: 2024-08-06 ## Description + This release is a hotfix for the package version. ## Commits + - No commits found. diff --git a/releases/v6.1.2.md b/releases/v6.1.2.md index 91fe058..7e19572 100644 --- a/releases/v6.1.2.md +++ b/releases/v6.1.2.md @@ -1,10 +1,13 @@ # Release v6.1.2 + Date: 2026-02-07 ## Description + This release focuses on project robustness and delivery quality. It adds a comprehensive suite of unit and case-based tests, plus CI workflows to run PHPUnit and PHPStan. It also includes extensive documentation and an automated release pipeline that produces artifacts (source ZIP and documentation PDF) with versioned release notes. The engine received a small tag/dialect handling refactor to enable future improvements without impacting expected performance. ## Commits + - [Update .gitignore to exclude __pycache__ and build directories; enhance sanitize_markdown_for_pdf to escape dollar signs](https://github.com/divengine/div/commit/de64b216f6fff9a1c010e31bb856694bc44b5be5) - [Merge branch 'develop' of github.com:divengine/div into develop](https://github.com/divengine/div/commit/7fd6a985f11dc10abb54b81ce801e8fbfbd3438b) - [Update ChangeLog for release v6.1.2 to include additional recent commits](https://github.com/divengine/div/commit/09acfcef1847239e772400e27ca206d9606b409f) diff --git a/releases/v6.1.3.md b/releases/v6.1.3.md index be34ef7..7fe7e63 100644 --- a/releases/v6.1.3.md +++ b/releases/v6.1.3.md @@ -1,10 +1,13 @@ # Release v6.1.3 + Date: 2026-02-07 ## Description + This release focuses on documentation clarity and release tooling. It refines the engine overview and parsing behavior guidance, improves release note generation logic, and aligns workflow configuration with the current versioning and release process. ## Commits + - [chore(release): update release notes for versions v1.1.0 to v6.1.3](https://github.com/divengine/div/commit/ca34786a025838f841ad76632665f2a23ebfa04a) - [Update documentation: enhance the overview and clarify engine behavior and core operations](https://github.com/divengine/div/commit/6e92000055dc530d3f0b05622f5b7dc6ee2bf1be) - [Update documentation: add notes on parsing behavior, loop control, and engine setup variables](https://github.com/divengine/div/commit/756a5c835a86eb5dd1a57400cd108359a4aaa7c3) From 2dc69d401651e806f346b79d52c3165c644793d2 Mon Sep 17 00:00:00 2001 From: rafageist Date: Sun, 8 Feb 2026 12:34:44 -0300 Subject: [PATCH 9/9] Update release date in v6.1.3 notes and adjust commit list formatting --- releases/v6.1.3.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/releases/v6.1.3.md b/releases/v6.1.3.md index 7fe7e63..cc88038 100644 --- a/releases/v6.1.3.md +++ b/releases/v6.1.3.md @@ -1,13 +1,13 @@ # Release v6.1.3 - -Date: 2026-02-07 +Date: 2026-02-08 ## Description This release focuses on documentation clarity and release tooling. It refines the engine overview and parsing behavior guidance, improves release note generation logic, and aligns workflow configuration with the current versioning and release process. ## Commits - +- [chore(release): update release notes](https://github.com/divengine/div/commit/4eb5fc37c9a96fc922eb7d85e18092290766f05c) +- [chore(release): update release notes](https://github.com/divengine/div/commit/9a13a06d41375061a013102e5d3e5e3ff66a9eae) - [chore(release): update release notes for versions v1.1.0 to v6.1.3](https://github.com/divengine/div/commit/ca34786a025838f841ad76632665f2a23ebfa04a) - [Update documentation: enhance the overview and clarify engine behavior and core operations](https://github.com/divengine/div/commit/6e92000055dc530d3f0b05622f5b7dc6ee2bf1be) - [Update documentation: add notes on parsing behavior, loop control, and engine setup variables](https://github.com/divengine/div/commit/756a5c835a86eb5dd1a57400cd108359a4aaa7c3)