Skip to content

Commit ab0c2bc

Browse files
committed
Implemented prop when. Tagged missing prop commands
1 parent a33febf commit ab0c2bc

File tree

8 files changed

+44
-11
lines changed

8 files changed

+44
-11
lines changed

RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Just a quick corrective version over v0.3.7 to fix the behaviour of several untested features, like the newly added filters of `for` loops.
44
This release also introduces few more meta-expression operators to allow escaping, and a realistic example emitting HTML to complement the rest of the docs.
55

6+
### New features
7+
8+
- `when` as a prop command for the conditional rendering of the owner.
9+
610
### Breaking changes
711

812
- `sort-by` and `order-by` will now use `|` in place `,` to split multiple options.

TODO.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ This is a list of commands which are currently supported:
2727
- [ ] for-prop (mostly a copy & paste from `for`)
2828
- [ ] value
2929
- [ ] prop (dual of element)
30-
- [ ] calc
31-
- [ ] log to add entries to the logging data
30+
- [x] when
3231

3332
## Missing features
3433

@@ -49,7 +48,7 @@ Just a corrective versions.
4948

5049
## `v0.3.11`
5150

52-
- [ ] Add support for props-based commands.
51+
- [ ] Add support for all props-based commands.
5352
- [x] Complete more of the repl vm operator to cover specs.
5453

5554
## `v0.3.13`

docs/releases/v0.3.5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## `v0.3.5`
1+
## v0.3.5
22

33
Technical release, only for the sake of fully testing workflows.
44

docs/releases/v0.3.9.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## v0.3.9
2+
3+
Just a quick corrective version over v0.3.7 to fix the behaviour of several untested features, like the newly added filters of `for` loops.
4+
This release also introduces few more meta-expression operators to allow escaping, and a realistic example emitting HTML to complement the rest of the docs.
5+
6+
### New features
7+
8+
- `when` as a prop command for the conditional rendering of the owner.
9+
10+
### Breaking changes
11+
12+
- `sort-by` and `order-by` will now use `|` in place `,` to split multiple options.
13+
- `when`/`is` fully replaced. The older syntax was dreadful but necessary without the RPN virtual machine, but now that we have... say hello to `test`/`case`.

docs/syntax.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
title: Full Syntax reference
33
---
44

5+
> [!WARNING]
6+
> This documentation reflects the expected functionality for v0.5.0.
7+
> Some features are still missing, progress is tracked in the repository and on the todo file in root.
8+
59
`vs.templ` uses special elements and attributes to define which actions the preprocessor should perform.
610
These XML entities are scoped under the namespace `s` by default, but the user can set up a custom one as well.
711
Please, notice that pugixml on which vs.templ is based does not have a full understanding of XML and namespaces are not covered.
@@ -102,7 +106,7 @@ The symbol `$$` gets loaded with the entry number while iterating, so that it is
102106

103107
To introduce the result of a (meta) expression in the tree.
104108
Numbers are serialized and added, strings are introduced as they are, attributes as strings and nodes are just appended as children.
105-
It accepts a an expression `src` as argument, by default set to `$`.
109+
It accepts an expression `src` as argument, by default set to `$`.
106110

107111
### `element`
108112

examples/html/template.xhtml5

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
<body>
1515
<main class="container">
16+
<!--TODO: once more operations are defined add a more complex test for when-->
17+
<h1 s:when=": false">Hello!</h1>
1618
<table>
1719
<thead>
1820
<tr>
@@ -25,7 +27,7 @@
2527
<s:for src="/entry" sort-by="$~name|$~surname" filter=": true">
2628
<s:item>
2729
<tr>
28-
<td><img s:eval.src="$~pic" /></td>
30+
<td><img s:value.src="$~pic" /></td>
2931
<td>
3032
<s:value src=": `$~surname` `$~name` `# ` join" />
3133
</td>

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project(
22
'vs-templ',
33
['cpp'],
4-
version: '0.3.8',
4+
version: '0.3.9',
55
meson_version: '>= 1.1',
66
default_options: ['cpp_std=c++20'],
77
)

src/vs-templ.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,22 @@ void preprocessor::_parse(std::optional<pugi::xml_node_iterator> stop_at){
648648
int offset = get_or<int>(resolve_expr(current_template.first->attribute("offset").as_string("0")).value_or(0),0);
649649

650650
auto expr = resolve_expr(in);
651-
651+
log(log_t::ERROR, std::format("static operation `{}` not yet implemented",attr.name()));
652+
}
653+
else if(cexpr_strneqv(attr.name()+ns_prefix.length(),"for-props.src.")){
654+
log(log_t::ERROR, std::format("static operation `{}` not yet implemented",attr.name()));
655+
}
656+
else if(cexpr_strneqv(attr.name()+ns_prefix.length(),"prop.")){
657+
log(log_t::ERROR, std::format("static operation `{}` not yet implemented",attr.name()));
658+
}
659+
else if(cexpr_strneqv(attr.name()+ns_prefix.length(),"value.")){
660+
log(log_t::ERROR, std::format("static operation `{}` not yet implemented",attr.name()));
661+
}
662+
else if(cexpr_strneqv(attr.name()+ns_prefix.length(),"when")){
663+
auto test = get_or<int>(resolve_expr(attr.value()).value_or(false),false);
664+
if(!test)last.parent().remove_child(last);
665+
break;
652666
}
653-
else if(cexpr_strneqv(attr.name()+ns_prefix.length(),"for-props.src.")){}
654-
else if(cexpr_strneqv(attr.name()+ns_prefix.length(),"use.src.")){}
655-
else if(cexpr_strneqv(attr.name()+ns_prefix.length(),"value.")){}
656667
else {log(log_t::ERROR, std::format("unrecognized static operation `{}`",attr.name()));}
657668
}
658669
else last.append_attribute(attr.name()).set_value(attr.value());

0 commit comments

Comments
 (0)