This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

cpass78
cpass78

One of my template files has an ampersand in the text which seems to break the page. I am getting: "We're sorry, but an unhandled error occurred. Please see the details below. Unexpected character "&"".

This block of text: "You have complete control over the look & feel of your website"

Stupid Twig, any ideas how to fix this as I would like to use ampersands.

Thanks

aaron677
aaron677

Can you use an HTML encoded Ampersand?

You have complete control over the look & feel of your website

Like that?

cpass78
cpass78

nope, same error.

cpass78
cpass78

Bump.. Any dev insight?

cpass78
cpass78

Now for some reason I am getting this with javascript as well.. My index page has a js slider that works just fine but moving to the about page which has similiar js in the exact same format spits out:

Unexpected character "$" line 149: $(function() {

This makes no sense, it's the exact same code..

daftspunky
daftspunky

Can you paste the complete page code you are using?

cpass78
cpass78

Sure, this is the index page which renders correctly: http://laravel.io/bin/ny99W

And this is the about page which is displaying the error: http://laravel.io/bin/XLjjq

Thank you for taking a look

cpass78
cpass78

bump, error still persists..

Daniel81
Daniel81

I have tried to replicate this error in Layout, Page, Partial and Content templates, using both the & and &amp; variations, outputting as HTML code in a <p> tag and as a Twig {{ "string" }} and don't get any errors - how are you injecting the code into your layout?

Last updated

cpass78
cpass78

Fixed it, missing curly brace in the template.. I dislike twigs error reporting very much.

martiendt
martiendt

Hi, how you solve that, i still got this error message

"Unexpected character "&" in "__string_template__07bf747766b2eecbc58cda608ded4df65f43f0d6f26eb9fbe34dacf0afb39b3b" at line 1." on line 284 of /home/vagrant/Code/test/public/vendor/twig/twig/lib/Twig/Lexer.php

and this is my email template

Name : {{ name }}
Email : {{ email }}

{{ description }}

it's working well if i remove {{ description }} which is that is textarea

Last updated

martiendt
martiendt

after trial and error it's worked now i just need to remove space between variables and curly braces i use {{description}} instead {{ description }} i don't know why but it's worked

billyZduke
billyZduke

Just experiencing this error for the first time. The partial I'm having trouble with is relatively complex from a TWIG-parsing standpoint: There are numerous translatable {{ "strings"|_ }}, and I'm also using jQuery plugin Tooltipster to produce tooltips, with the contentAsHTML property set to true, which allows for encoded tags to be included in the tooltip elements' title attributes, so that means I've got multiple lines that look like the following:

{{"WYSIWYG"|_}}<span class="tooltip" title="&lt;span&gt;({{"What You See Is What You Get"}})&lt;/span&gt;">✽</span>

Removing the spaces between the brackets and the strings has not cleared up the error or caused a different one, but I'm still experimenting, so I will post whatever solution I find if and when I find it...

billyZduke
billyZduke

Well, turns out to have been just another case of lousy TWIG error reporting. I had one translatable string that began with a double-quote but ended with a single-quote, and that was fouling everything up. During my debugging, I did manage to get a different error message than the original one about the ampersand (which clued me into the actual syntax error) by replacing all my HTML-encoded attributes with stuff like this:

{{ '</span>'|e('html_attr') }}

But having fixed the mismatched quotation marks, I'm rolling all that back and it's still working now...

hoangphuc5017161
hoangphuc5017161

Just create new email template and paste current mail template to created. it work.

1-15 of 15

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.