Unless a Replacement Variable is added to the "Then output this..." or "Otherwise, output this..." fields, any HTML entered into these fields is output "escaped", i.e. as plain text with "&lt;" and "&gt;" entities instead of angled brackets ("<" and ">").

A simple workaround is to create an empty "Global: Custom text" field, and add this as a Replacement Variable to the fields above.

Comments

Onein created an issue. See original summary.

robbm’s picture

Issue summary: View changes
codesmith’s picture

Priority: Minor » Normal

This just happened to me too. Thanks for the workaround. It's displaying HTML correctly in other views. Can't figure out what's different in this view.

chucksimply’s picture

Yup, same thing happening to me as well.

naresh_bavaskar’s picture

StatusFileSize
new35.83 KB
new257.23 KB

i am unable to re-produce this issue.
steps i have followed:
1) created dummy contents, and created view.
2) added view conditional fields, added html text in `Then output this...` field
3) in output -> not able to see "<" and ">" (i can see proper output here)

please find the attached screenshot for more information.

let me know if i missed any anything on it.

freddy rodriguez’s picture

StatusFileSize
new25.24 KB
new28.4 KB

I can confirm the problem. I have attached the screenshots of the field setup (Captura1), and the view output (Captura2)
Regards

Freddy

shelane’s picture

Status: Active » Needs review
StatusFileSize
new1.12 KB
new825 bytes

There were only two commits made that have the potential to cause this issue. Please see which patch fixes it.

dbielke1986’s picture

https://www.drupal.org/files/issues/2020-10-13/3053293-translate.patch

=> Is woking for me and version 1.1 of this module.

dbielke1986’s picture

Status: Needs review » Active

The problem I see is to use t() to render the output. It will fill up the drupal user interface translation table with every output.

In my opinion it would be better to use html like this

$result =  array(
  '#markup' => 'Hello. This is my First Page',
);
$renderer = \Drupal::service('renderer');
$html = $renderer->render($result);
shelane’s picture

That is why I took them out originally. I restored so that I could get a fix out quickly. I will look at the suggested solution in a few weeks when I have some time to look at it. If you want to submit a patch, that would be great too.

dbielke1986’s picture

Status: Active » Needs review
StatusFileSize
new1.24 KB

Hi Shelane,

attached you will find my patch to review. It seems to work fine for me.

dbielke1986’s picture

Version: 8.x-1.0 » 8.x-1.2
freddy rodriguez’s picture

Hello Shelane 8.x-1.2 Works perfect!

shelane’s picture

Status: Needs review » Needs work

The patch caused errors when the $equalto, $then, $or variables are later run through other str_replace functions.

dbielke1986’s picture

Status: Needs work » Needs review
StatusFileSize
new6.27 KB

Ok, I did not run into these problems, but I think this is a valid point.

Therefore:
Next try. This patch fixes the problem for me as well and does not write strings into the translation table.

chucksimply’s picture

Patch from #15 worked for me on 1.2 (#11 patch wouldn't apply). Thanks for the work!

shelane’s picture

StatusFileSize
new6.46 KB

Updating patch for testing. This patch differs from the previous only in the path of the source file.

  • shelane committed 1fbbe28 on 8.x-1.x authored by JD_1
    Issue #3053293 by shelane, JD_1, Freddy Rodriguez, naresh_bavaskar: HTML...
shelane’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

anybody’s picture

Follow-up as this removed translations completely in dev while they were enabled by default in 8.x-1.2. The next release from current dev would break this functionality!

#3195086: Add option for translation and exclude replacements from translation

eit2103’s picture

Ran into the same problem, following this topic as well.

anybody’s picture

@eit2103: Then it would perhaps help if you could review #3195086: Add option for translation and exclude replacements from translation :)

tahu22’s picture

This issue is still active in 8x-1.5. I needed to go back to 8x-1.2 and apply the patch

anybody’s picture

@shelane (Maintainer) is @Tahu22 right? If yes, was this removed by accident? Do you have tests to ensure this won't break again? Reopen? Or is he just wrong?