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

Example does not render as html? #141

Open
daslicht opened this issue Aug 7, 2015 · 8 comments
Open

Example does not render as html? #141

daslicht opened this issue Aug 7, 2015 · 8 comments

Comments

@daslicht
Copy link

daslicht commented Aug 7, 2015

Is it normal that html tags are not rendered but output as string ?

http://leonidas.github.io/transparency/
?

@rikukissa
Copy link
Contributor

By looking at the code it surely seems that it's intentional 😕. @pyykkis has it always been like that and is it intentional? Maybe it should be replaced with some other example either way

@rikukissa
Copy link
Contributor

The "Goodbye!" is also not rendered so I'm guessing thats not intentional..

@daslicht
Copy link
Author

daslicht commented Aug 8, 2015

if you add _class= "span"_ to the span _Goodbye!_ is rendered :)

@bertday
Copy link

bertday commented Mar 17, 2016

I love this project but I'm running into the same issue -- HTML is being rendered as plain text.

+1

@kristoff-it
Copy link

@rbrtmrtn

Maybe I didn't properly understand the question, but when I want to render a property as HTML, I use the relative directive:

myobj = { description: "<i>banana</i>" }
mydirective = {description: {html: function (params) {return this.description}}}
$("<div class='mainbody'>\n\
        <div class='description'></div>\n\
</div>").render(myobj, mydirective)

Result:

<div class='mainbody'>
    <div class='description'><i>banana</i></div>
</div>

@bertday
Copy link

bertday commented Mar 18, 2016

@kristoff-it I wasn't aware of the relative directive, perhaps that would solve it. (Though it seems like a lot of overhead to include arbitrary HTML in a template). I was mainly confused as to why the demo itself doesn't seem to be rendering properly:

http://leonidas.github.io/transparency/

In the Result pane, shouldn't that text be italicized?

@kristoff-it
Copy link

Uhm yeah that's weird, I suppose it's something that has been left behind from the earlier days of this project.

I've only used transparency for one project as of now, so I'm not a super expert, but:

Though it seems like a lot of overhead to include arbitrary HTML in a template

If the HTML in question is generated by you in the browser, I suggest you try to change how your app is structured to make, for example, transparency handle also that rendering.

If the HTML is recieved as-is, then you don't have much choice I guess, but it's not that bad, in my project I have to render some RSS feeds like this and, while the syntax is not the most concise, it still works flawlessly. I still prefere this over weird naming conventions a la Ruby.

Alternatively you could $.html(function) all the html contents afterwards: http://api.jquery.com/html/#html2 (if you pass a function you can have a form of iteration over your data structure).

@bertday
Copy link

bertday commented Mar 18, 2016

Those seem like good workarounds, thanks @kristoff-it ! 👍

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

No branches or pull requests

4 participants