Search code examples
orchardcms

Orchard cms token json


I would like to format a json payload in a workflow activity. I use the new {Text.JavaScriptEncode} to enclose my properties in {}. I should do it wrong because the tokens are not evaluated anymore. So if i use

{Text.JavaScriptEncode}{
"Courriel":{FormSubmission.Field:Courriel}
{Text.JavaScriptEncode}}

It ends with the following value:

{
"Courriel":{FormSubmission.Field:Courriel}
}

So the {FormSubmission.Field:Courriel} is not evaluated. If i don't specify {Text.JavaScriptEncode} before the first {, nothing is rendered (empty string).

I'm using Orchard 1.10.1.0


Solution

  • You might need to turn on the Tokenizers HashMode.

    I haven't tested your token but I'm pretty sure the tokenizer tries to evaluate this as a token and fails:

    {"Courriel":{FormSubmission.Field:Courriel}
    

    With hashMode enabled your code will look like this:

    #{Text.JavaScriptEncode}{
    "Courriel":#{FormSubmission.Field:Courriel}
    #{Text.JavaScriptEncode}}