scryber.core
scryber.core copied to clipboard
Can't seem to put text and bound values together
I want in the src attribute for instance a dynamic value that exists of plain text and a bound value:
<img src='MaterialIcons/{@:.TransportSubType}.png' />
```
Is there also a way to implement If and Switch?
Hi Jeroen - it’s a big question, and something I’m really keen to solve as I’ve been looking at for a while with things like handlebars and mustache too.
However I have just put some documentation on the use of template controllers taking your need as the first case. I hope it may help … https://scrybercore.readthedocs.io/en/latest/document_controllers.html
@jeroenvipper about the If/Switch, this is basic but it works:
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'
xmlns:data='http://www.scryber.co.uk/schemas/core/release/v1/Scryber.Data.xsd'
xmlns:styles='http://www.scryber.co.uk/schemas/core/release/v1/Scryber.Styles.xsd'
xmlns:doc='http://www.scryber.co.uk/schemas/core/release/v1/Scryber.Components.xsd'>
...
<data:Choose>
<data:When test="{@:.UseLayout1}">
<Template>
...conditional stuff here
</Template>
</data:When>
<data:When test="{@:.UseLayout2}">
... other stuff here
</data:When>
</data:Choose>
...
note the upper case T in the <Template>
tag, it's not the same as <template>
! The UseLayout1 model member is a boolean, I couldn't get the xpath conditional syntax to work, probably because I don't understand it very well!
Thank you very much!
That's great Tim - thanks. Resident expert :-)
@jeroenvipper - how did you get on? Were you able to get your required output?
Yes Richard, it's going very well using the controller as you suggested! Thanks for all the help so far!
Hi Jeroen - We have checked in and put a beta nuget package of 5.1 out there that supports the handlebars expressions. Looks to be working really wel based on the Expressive library (https://github.com/bijington/expressive).
We have used the handlebars syntax {{…}} to differentiate with the {@: } syntax and it has full support for functions, parameter references, aggregates and general math equations. See the attached from our unit tests for reference. Hopefully we can get this pushed live soon.
It has been a while, but if still needed I hope it is useful.