Any way to defeat validation?

I’m using a template to insert code into a script. Because I’m inserting into the middle of the script, my code starts with a closing tag </mj-text> and ends by reopening that tag <mj-text>

Even though those aren’t L&L tags, the L&L editor tells me those tags must be paired, and doesn’t pass them on.

It would be useful to have a tag e.g. <Raw> </Raw> that ignores validation for whatever is inside.

Is there any other way to defeat that validation and force L&L to pass those tags?

I’m not sure I quite understand what’s going on here, so maybe you could elaborate a bit more to help me. When you say “I’m using a template to insert code into a script,” do you mean that you’re writing a JS script in the Template code editor? Or are you somehow saving a template variable and then trying to pass it as a variable into the Script tab in the L&L editor interface? I’m also curious about what exactly is happening when you say that L&L “doesn’t pass them on.”

In my experience, if you “break” HTML syntax, you’d kinda expect L&L to complain a bit. So for example, if I wrote a template like the one below, I’d expect it to throw some errors because the editor can’t understand that even though I’ve written an <h1> tag all by itself and have two closing </h1> tags, I’ve accounted for this “incorrect syntax” with my conditional logic.

<If field=title exists>
  <Field title /></h1>
  <Else />
  Placeholder title</h1>

I would want the editor to point out my mistake because if the logic didn’t work out, I could end up with a broken template that might not render. The template above technically works and renders as expected, but the editor can’t necessarily know that it will work once it’s rendered. All it knows is that as it’s written, it doesn’t follow the correct HTML/L&L syntax. In my example, the correct approach would be to modify the template to put a single closing </h1> tag after the closing </If> tag. I wonder if there would be a way to modify the way you’re approaching your template to avoid the validation messages. The fact that L&L “doesn’t pass them on” suggests that maybe there is actually an issue with the template, but I’m not sure how to replicate this without more details.

Anyway, I’d be curious to hear more about where this is causing you issues!

Edit: just kidding, that template doesn’t work. When the condition is false, the output is:

Placeholder title
1 Like

Good questions.

In my posts (Gutenberg) I use a shortcode to call a Tangible Template that inserts a specified quote from my quote CPT. It works quite well, until I want to send my post in an email.

Since email readers aren’t compatible with a lot of web HTML/CSS, I wrote a PHP snippet that refactors my posts into an email-specific Markdown Language called MJML. Everything works well except my quote inserts need to start by closing some Markdown tags in the email and end by opening them back up. (It’s a weird situation, but I haven’t found a way to work around that requirement.)

When I include those unconventional tags in my Tangible Template, they do not appear in the output ML that my snippet creates.

I understand why the default behavior for Tangible Templates is to not allow “dangling” tags, which is why I suggested that overriding that behavior could require an explicit, overt tag (e.g. <Raw> </Raw>) that tells the Tangible Template “I know these tags break the rules, but I want to do it anyway.”

At this point, I’ve created my own shortcode that can return “dangling” tags without being “corrected” because they don’t involve Tangible Templates. To refactor my post for email, I first do a str_replace to change the name of my Tangible Template shortcodes and replace it with the name of my PHP shortcode. Then I run do_shortcode and it works perfectly.

So I don’t really need anything, but I thought I would document the situation here.

P.S. I just re-read my original post and saw that I forgot to include the backtick(?) marks around <Raw> </Raw> so it didn’t show until now. How meta.

1 Like

You can defeat template validation by inserting things with a shortcode e.g.

<Shortcode>[insert-text txt=end]</Shortcode>

I created theinsert-text shortcode to accept keywords that return a block of text predefined in the shortcode

1 Like