scryber.core icon indicating copy to clipboard operation
scryber.core copied to clipboard

Can't seem to put text and bound values together

Open jeroenvipper opened this issue 3 years ago • 7 comments

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? 

jeroenvipper avatar May 14 '21 13:05 jeroenvipper

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

richard-scryber avatar May 16 '21 20:05 richard-scryber

@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!

tim-biasoft avatar May 17 '21 09:05 tim-biasoft

Thank you very much!

jeroenvipper avatar May 17 '21 09:05 jeroenvipper

That's great Tim - thanks. Resident expert :-)

richard-scryber avatar May 17 '21 14:05 richard-scryber

@jeroenvipper - how did you get on? Were you able to get your required output?

richard-scryber avatar May 26 '21 14:05 richard-scryber

Yes Richard, it's going very well using the controller as you suggested! Thanks for all the help so far!

jeroenvipper avatar Jun 08 '21 14:06 jeroenvipper

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.

bindcalcallfunctions.pdf

richard-scryber avatar Jul 19 '21 17:07 richard-scryber