I use TinyMCE 4 as a WYSIWYG editor for HTML pages. But when I use FreeMarker tag idioms like <#if condition>
, <#else>
in TinyMCE, they get mangled when I go from "code view" (simple textarea) to the "design view" (WYSIWYG).
For example if I write HTML in a simple textarea (Code view)
<#if x == 1>
x is 1
<#else>
x is not 1
</#if>
and then toggle to editor and back to Code view, it becomes:
<#if x == 1>
x is 1
<#else/>
x is not 1
</#if>
As you can see FreeMarker tags are getting escaped in the toggling.
Q1: Is there a way to configure TinyMCE to handle these tags so that when I toggle back-and-forth between the editor and the Code view the markup remains consistent?
Q2: Or (saying the same thing in a different way) does TinyMCE have support for FreeMarker?
What have I tried so far?
[#tag]...[/#tag]
is treated as plain text by TinyMCE.I've tried to disable HTML validation in configuration:
verify_html: false,
valid_elements: '*[*]',
In the TinyMCE Editor I hit the HTML icon, and edit it from there. Once I click "ok" it goes away. So there's no need to save it to see the html tags gone . More sharing options...
The kind of automatic escaping described here requires at least FreeMarker 2.3.24. If you have to use an earlier version, use the deprecated escape directive instead. Each template has an associated output format (a freemarker.core.OutputFormat instance) .
Furthermore it's recommended that FreeMarker is configured so that templates with ftlh and ftlx file extensions are automatically associated with the HTML and XML output formats, respectively. The predefined output formats are: Default implementation ( freemarker.core.*) Doesn't escape.
Furthermore it's recommended that FreeMarker is configured so that templates with ftlh and ftlx file extensions are automatically associated with the HTML and XML output formats, respectively. The predefined output formats are:
I think you will have to un-mangle them in a custom freemarker.cache.TemplateLoader
implementation, which wraps your normal TemplateLoader
. Though of course, there will be an ambiguity if the user indeed types "<#" or "</#", but I'm not sure if that's a problem in your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With