Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using {{html}} with a string that includes a tag parameter of "tmpl" throws an error #42

Closed
GeoffreyBooth opened this issue Jan 10, 2011 · 6 comments

Comments

@GeoffreyBooth
Copy link

The error:
Uncaught TypeError: Cannot call method 'push' of undefined

is thrown in Chrome 9 for Windows, or the error:
is null or not an object

is thrown in Internet Explorer 8 for Windows, for the following template:
{{html trailer}}

where trailer equals:

When I add this line of code before trailer gets processed by the template, the error goes away:
trailer = trailer.replace(/tmpl/g, 'null');

@BorisMoore
Copy link
Owner

It works for me. Can you provide full repro, e.g. on http://jsfiddle.net/?

Is trailer a string of HTML markup or reference to an HTMLElement? Looks like you have created that trailer object by rendering another template?

I think you need to show your scenario in a repro for us to be able to determine whether this is a bug.

@GeoffreyBooth
Copy link
Author

trailer is a string. You're right, it looks like it was corrupted by another template. In my backend admin page I have something akin to
<textarea>{{html trailer}}</textarea>
which introduces the _tmplitem tags into the trailer markup. Looks like I might've found two bugs.

I'm trying to set up a repro on jsfiddle but no luck so far . . .

@GeoffreyBooth
Copy link
Author

Example on jsfiddle: http://jsfiddle.net/DiegeticShadow/YdWL5/

@BorisMoore
Copy link
Owner

You need
<textarea>${trailer}</textarea>
since you want to show the markup in the textarea, not insert HTML child elements to the textarea.

For the rest, I'll look at it at some point. (Not able to do so immediately though...).

@BorisMoore
Copy link
Owner

Comment received from gordonslondon:

i'm having the same problem:

  • I make an ajax request wich return <textarea><b>Welcome</b></textarea>, i assign this html to the variable my_html
  • then i render a template like this "
    {html my_html}
    "

the content of the textarea is now: <b _tmplitem="8" >Welcome</b> insteadof <b>Welcome</b>.

Is there any workaround ? or maybe i'm missing another thing ..
thank you

My reply:

You need to escape the content of the text area. <textarea>&lt;b>Welcome</b></textarea>
Or at least the first <, as shown.
There is no automatic detection of textareas, so no built-in handling of this issue.

@BorisMoore
Copy link
Owner

See also #46

Closing

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants