Adding mustache template variables while editing in TinyMCE - tinymce

I'd like to use the TinyMCE editor to write text that includes Mustache template variables, specifically to include repeating groups. I'm willing to use the html code view within TinyMCE if I have to (this is definitely a rarer use case).
I can do it just fine with an ordered list. That is, in the code view I can write
<p>Blah blah blah</p>
<ol>
{{#info.courses}}
<li>{{course}} -- {{course_title}}</li>
{{/info.courses}}
</ol>
<p>All done!</p>
and I get a nice ordered list of all the courses and titles.
However, if I try the same thing with a table (replace <ol> with <table>, etc) TinyMCE rearranges the code when I exit the HTML code view. It removes the repetition tags and places both in a paragraph before the table.
Any way to get TinyMCE to leave my changes to the HTML alone?
I realize it is asking a lot to change the representation of what TinyMCE is working on, but thought I'd ask.
Alternatively, any suggestions on other approaches to include Mustache tags in the contents of the editor?
I'm currently using version 4.9.4.

Related

How do you AB test with Google Optimize on elements that have dynamic variables?

Im currently using Google Optimize's editor and I need to make an edit on an element that contains some dynamic variables. However when I edit the html, it renders the plain text and therefore it updates without the dynamic variable in place.
For example in the code it might be set up as <p>{{ user.name }}</p> but when I use the editor to edit the html it will show it as <p>John Smith</p> but if I apply changes it will replace my dynamic variable with the plain text.
Is there a solution for this?
You can try instead of editing the HTML via replace, you can insert/append/prepend.
Of course, this might mean you need to do some clever things with your code. Provide the before and after in your question and we can talk specifics.
Another thing you can try is to not use edit HTML and just use the editor to change the styling.

Is it possible to create your own drag and drop Mailchimp template?

I'd like to create a custom drag and drop template so I can increase the design possibilities without losing the functionality. I can't find anything in their documentation.
I was hoping to create something like this, not sure if I'm missing something obvious but I can't find a drag and drop that allows for the different coloured background with columns too.
I could use a block of code but I can't edit the css styles so it wouldn't be responsive for mobile and also not very friendly for those who don't know html.
Rather old question, but to who it might be helpfull:
If you code your own template and upload it to Mailchimp you lose the 'drag & drop' system/UX interface with the different blocks. You are able to create repeatable blocks but then it works with a dropdown list. This is (in my humble opinion) not that user friendly and takes a while before you fully understand how to use the dropdown. I had to explain it to a client earlier today and took a while before they understood it, so I decided to write them a manual for it.
But the design you want to create should be possible to make with a standard MC template. In the 'design' tab you will find settings to control background colors etc.
Still not possible, answer from the Mailchimp support: "At the moment, it's not currently possible to code a drag and drop template completely--one of our drag and drop template layouts will need to be selected, but you can drop in Code blocks to get a little more control over the styling of certain sections."
Though, if it's any help, it is possible to fully custom code your own template, and then add in mailchimps special Template language to the template to open up sections as editable within the campaign builder--or even duplicate certain sections of content. It's not quite the same as the drag drop templates, but adds similar functionality. More info on working with template language can be found here: https://mailchimp.com/help/getting-started-with-mailchimps-template-language/
I know this is an old question, but while searching for this myself I stumbled upon a solution posted here.
Basically it is possible to code your own drag n' drop template, but the solution has not been documented.
Find one of the Mailchimp templates (either one of the basic templates or a custom template from the 'Themes' menu.
Use 'Inspect element' and copy the source code of the iFramed html-email.
Paste in your preferred HTML-editor and modify as intended
Create your own template from the 'Paste in code' mode
If you want custom modules to be added by default, edit using the menu 'Edit design' in the bottom of the screen.
Save and exit :)
I found part of the answer on another topic: [Is it possible to code drag&drop templates for mailchimp?
If you add the following code into your main content div or td it will enable the drag and drop block editor:
mc:container="body_container" mccontainer="body_container"
example:
<div mc:container="body_container" mccontainer="body_container"></div>
This code will add a block editor region to the preheader section:
mc:container="preheader_container" mccontainer="preheader_container"
For the header:
mc:container="header_container" mccontainer="header_container"
For the footer:
mc:container="footer_container" mccontainer="footer_container"
Note: It doesn't seem to matter what you call the mc:container. Creating a new container with a different name worked. Although using just mc:container tag seems to work at first by itself, the mccontainer (no colon) tag is required for it to save properly.
You can create your own drag and drop template you need to add the following into your html coded template where you want the 'drag and drop' feature to exist.
<div id="templateBody" mc:container="container_name" mccontainer="container_name" class="tpl-container">
<div mc:block="3502204" mc:blocktype="text" mcblock="3502204" mcblocktype="text" class="tpl-block"></div>
</div>
This can be repeated in your code multiple times for multiple insertions. I could not find documentation to indicate if the container name or block number needs to be unique, I did make it unique in my template.

RichText in Magnolia CMS is changing HTML text

I would like to ask how I can block richText from changing html text under source view.
I'm using Blossom module and defined richText as #Chris J advised me to do:
Add source button to Magnolia CMS richText control
Whenever I put html code in source code, switch to normal view and get back to source view the code is changed. For example the following part of code is missing :
<div class="components"> <div class="product col img-slider"> <div id="product-image" class="royalSlider productImage rsDefault"> <div class="rsContent"> <div class="rsTmb"><img src="/magnoliaPublic/resources/XXX/products/product_7.jpg" alt="">
and is replaced with folowing
<p><img alt="" src="/magnoliaPublic/resources/XXX/products/product_7.jpg" /></p>
I need to provide the possibility for the user to put html code and next to see in on the web page.
Regards
Jan
Jan. I'd ask why you are using a rich text area if you are entering HTML. It is not really designed for this usage. Would you be better off with an ordinary text field? In the STK (you mentioned this in your previous question) you will find a component that serves exactly this purpose.
Under "Configuration" you will find it at /modules/standard-templating-kit/templates/components/content/stkHTML
You will see that the template script is simply:
[#if content.editHTML?has_content]
${cmsfn.decode(content).editHTML}
[/#if]
If you want to stick with a purely Blossom approach, you may need to recreate this but it is an incredibly simple component.
Incidentally, in Magnolia 5.4 there is a code editing field used in a similar component that offers syntax highlighting. You can see this by logging into the demo site and trying to add an HTML component to the main area of the page travel/contact.

How to stop TYPO3 from stripping <p> tags from RTE content (or touching it at all)

I have a TYPO3 which strips any <p> tags from content I create when the RTE editor is enabled for the field in question before it saves it in the DB. And it seems I cannot find a way to disable this behavior with a TypoScript. As soon as I disable the RTE editor I can save <p> tags and they get correctly rendered in the frontend. They also get correctly rendered in the frontend when I simply add them directly in the database in the tt_content table in the bodytext field.
When I switch to the edit source mode of the RTE I see all <p> tags in place. Before and after a save (also they never make it to the DB) so it looks like they get converted to (linux) line breaks or something and get converted back to <p> tags when the editor loads them in the backend. But those line breaks of course have no effect to in the frontend.
I thought this behavior would be controlled by RTE.default.proc but everything there looks good to me (p is already in the allowed tags and there is no clue why it could be stripped). I've also tried to disable the RTE.default.proc.entryHTMLparser_db and RTE.default.proc.exitHTMLparser_db as I wouldn't mind it if the HTML content as you see it in the edit source mode of the RTE (so with RTE still enabled!) would not be touched at all - in fact I would prefer it - but this had no effect. On the other hand when I add tags to the allowed tags which weren't there before (like <button>) this works so the things I try to add to RTE.default.proc aren't ignored in general.
So how can I stop TYPO3 from stripping my <p> tags from RTE content or touching it at all? I'd prefer a solution with TypoScript but meanwhile I would also be happy about an ugly hack in a sys extension as long as it works...
I'm not sure if this is a bug or not but the solution to my problem lies in p.rmTagIfNoAttrib = 1. At least in my TYPO3 version (v6.1.7 and nearly only built in extensions) I cannot find this setting in the preset TypoScript of the page or the RTE editor so I'm guessing it defaults to 0. In my logic 0 means false so I'd say the default would read as "remove tag if there is no attribute?: no!".
However TYPO3 seems to work after its own logic. Adding the following statement to the page TS sloves my problem and <p> tags are preserved:
RTE.default.proc {
entryHTMLparser_db {
tags {
p.rmTagIfNoAttrib = 1
}
}
}
The reasons for this behavior are explained in the TYPO3 manual:
Many of the transformations performed back and forth in the TYPO3 backend date back to when it was a challenge to incorporate a RTE in a browser. It was then sometimes needed to fall back an a simple <textarea> where rich text had to be presented in a simple enough way so that editors could work with it with no visual help.

How to handle html templates in MVC2?

My (MVC2) application displays several addresses in a View.
Each address contains just a subset of information, like first- and lastname. The request is that the complete address information should be displayed when the mouse is over a result.
An html template should be used therefor.
This template defines how(!) the complete address should be displayed – but it doesn’t defines what(!) should be displayed.
Means it can be assumed that the complete address is always “firstname“, “lastname”, “street”, “zipcode” and “city” (for example and to keep it simple). This will never be changed.
But for example the background color can be changed in the html template from white to green or the size of the lastname can be changed from <h1> to <h2> …
What is the best way to solve it?
I would prefer to write some shared code (keyword: ascx).
This shared code should wrap the template, would be very easy and would look like this:
<div id=”mouseOver” style="display: none;" >
X_REPLACE_X
</div>
The template would look like this simplified example:
FirstName: {Name}<br/>
Lastname: <h1>{Lastname}/<h1><br/>
ZipCode: {ZipCode}<br/>
I would then render the ascx code via “Html.RenderPartial” on the View and map each address to a javascript mouseover function.
The javascript function would replace the placeholder (like {FistName}, {LastName} , etc.) in the template, position and display it.
And thats my problem:
The template should NOT be put directly in the wrapper (ascx - code)!
Means at runtime must “X_REPLACE_X” be replaced with a somewhere on the server stored template.
Because this gives me the ability to change the template without changing and publishing the code!
How can this be managed?
Is there a much better way to solve it? Should I use instead ajax calls to get the template in a variable?
Any help would be really great!
thxs in advance!
It sounds like the best way to accommodate your display differences is to simply use different css classes. The html template used for the full information does not change and can be used for all addresses, while the differences between background colors and text size can be handled by different css settings.
Relatedly, I wouldn't handle the different text sizes by using <h1></h1> and <h2></h2> but rather a common tag (such as <span></span>) whose text size is handled via css.