From 4ea133608350e6e99008f46cb4c45dd18989b836 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Mon, 6 Jan 2025 01:16:33 +0200 Subject: Implement `Iterate` parser. --- README.md | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 31bc1a0..032228e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ you to use any editor without needing any additional editor extensions.

-
+

@@ -50,8 +50,8 @@ A simple example of how to use HTMTL with default configuration looks like this: ```python from htmtl import Htmtl -htmtl = Htmtl('

', {'who': 'World'}) -html = htmtl.html() # returns:

Hello World

+template = Htmtl('

', {'who': 'World'}) +html = template.to_html() # returns:

Hello World

``` ## Attributes @@ -214,15 +214,14 @@ Results in: ``` -### `foreach` +### `iterate` Loops anything iterable. -For example, to loop over a collection of `posts` and then use `post` as the variable of each iteration, you can do something -like this: +For example, to loop over a collection of `posts` and then use `post` as the variable of each iteration, you can do something like this: ```php -
+

``` @@ -231,7 +230,7 @@ If you do not care about using any of the iteration data, you can also entirely like so: ```php -
+
...
``` @@ -239,7 +238,7 @@ like so: And, you can also assign the key of the iteration to a variable, like so: ```php -
+

``` @@ -313,12 +312,12 @@ You can add (or replace) parsers in HTMTL when creating a new instance of the `H from htmtl import Htmtl from htmtl.parsers import InnerText -htmtl = Htmtl('

', {'who': 'World'}) -htmtl.set_parsers([ +template = Htmtl('

', {'who': 'World'}) +template.set_parsers([ InnerText, ]) -html = htmtl.html() # returns:

Hello World

+html = template.to_html() # returns:

Hello World

``` Prsers must extend the `Parser` class, like so: @@ -354,7 +353,7 @@ HTMTL is built upon the [Dompa](https://github.com/askonomm/dompa) HTML parser, - `htmtl.parsers.OuterPartial` - Parser the `outer-partial` attributes. - `htmtl.parsers.OuterHtml` - Parser the `outer-html` attributes. - `htmtl.parsers.OuterText` - Parser the `outer-text` attributes. -- `htmtl.parsers.Foreach` - Parses the `foreach` attributes. (**soon**) +- `htmtl.parsers.Iterate` - Parses the `iterate` attributes. ### Modifiers @@ -364,12 +363,12 @@ You can add (or replace) modifiers in HTMTL when creating a new instance of the from htmtl import Htmtl from htmtl.modifiers import Truncate -htmtl = Htmtl('

', {'who': 'World'}) -htmtl.set_modifiers([ +template = Htmtl('

', {'who': 'World'}) +template.set_modifiers([ Truncate, ]) -html = htmtl.html() # returns:

Hello World

+html = template.to_html() # returns:

Hello World

``` Mdifiers must extend the `Modifier` class, like so: -- cgit v1.2.3