2

When I process a keyword like this:

  • In the HTML template I have:

    <p>@msg</p>
    
  • and in code I have:

    if SameText(AObjectName, 'msg') then
         AValue := 'Must be Logged In<br />This was not activated';
    

When it is processed the engine automatically encodes all the HTML so in the browser it is rendered like this:

    Must be Logged In<br />This was not activated

This is because the stencil processor processed it into this:

Must be Logged In&lt;br /&gt;This was not activated

I am expecting the browser to render it like this:

Must be Logged In
This was not activated

This means you can't output any HTML from the stencil keywords. Is there any provision for outputting HTML in the processed keywords?

1
  • Of course it does by default, since you might want to output texts like I <3 you, which would be invalid HTML. Also consider using punctuation when outputting text. Commented Oct 26 at 9:21

1 Answer 1

0

I couldn't find anything in the documentation about this but after looking at the source code for WebStencils I found:

    // suppress HTML encoding
    if LParser.Token = '\' then
       begin
        LEncode := False;
        LParser.SkipToken(False);
        LTokenStr := LParser.TokenString;
       end;

Which means if you put a \ in front of the WebStencil keyword it will not encode the HTML output. Like this - it will put:

Must be Logged In<br \>This was not activated

into the web page. So in the browser it is rendered like this:

Must be Logged In
This was not activated

Sign up to request clarification or add additional context in comments.

6 Comments

This is actually documented behavior: "Note: The output of values processed by WebStencils is encoded using the TNetEncoding.HTML.Encode method. You can suppress any encoding by using the syntax @\value."
I missed that part. Thanks.
You should update your answer.
It would be the right thing to do to update the answer. Stackoverflow isn't just for getting help oneself, but aims to create a collection of useful question-answer pairs that are as perfect as possible.
Isn't this a valid answer to the problem? You can give another valid answer to the problem too can't you?
Yes, the answer as it stands is a valid answer, too, but it'd be even better if it included the link to the documentation (that Remy provided in the comment) instead of stating "I couldn't find anything in the documentation about this". That would make the answer more trustworthy, and sound less like an informed guess (which is also good, but not the very best possible).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.