Coder Social home page Coder Social logo

Comments (10)

Caffeinix avatar Caffeinix commented on June 10, 2024 2

What @fprijate is asking for sounds to me like protection from XSS vulnerabilities. Speaking for myself, I would not expect HTML content added to $text to be active; that sounds like a pretty big security hole actually. In fact, if you do add an $html, I would recommend naming it something like $unsafeHtml instead to make it very clear that it must never be used to insert anything that comes from user content.

from cell.

codehz avatar codehz commented on June 10, 2024 2

Why not use innertext for $text and innerHTML for $html?

from cell.

gliechtenstein avatar gliechtenstein commented on June 10, 2024

Thanks for the suggestion, I just realized I forgot to mention how to create text nodes on the tutorial. Just added it. intercellular/tutorial@d7ec6e1

But I'll share it again here just for reference:

To create plain text nodes, you use $type: "text". For example, if you wanted to express something like this:

<div class='row'>
  <img src="http://localhost/img.jpg"> Plain text
</div>

You would write

Row = {
  class: "row",
  $components: [{
    $type: "img",
    src: "http://localhost/img.jpg"
  }, {
    $type: "text",
    $text: "Plain Text"
  }]
}

Now, as for why the attribute name is $text instead of $html (even though internally it uses innerHTML): It was because I actually don't want think it's good to use this for HTML.

Of course no one is stopping one from using HTML expressions inside (and sometimes it might be a nifty feature) but if we actually name the attribute $html, we're basically promoting that "you're supposed to use HTML instead of plain text expressions here", which is not what we want.

Hope this makes sense. Let me know if you have further questions or arguments. Love to discuss further

from cell.

fprijate avatar fprijate commented on June 10, 2024

Thanks for response.
I understood this before (from examples and my own code).

My intention is to get from:

Row = {
  $type: "div",
  class: "row",
  $text: " <span> test </span>" 
}
<div class='row'>
     &lt; span &gt; test &lt;/span&gt;
</div>

instead of

<div class='row'>
    <span> test </span>
</div>

Of course I can always make something like this:

Row = {
  $type: "div",
  class: "row",
  $text:  " <span> test </span>".replace(/</g, "&lt;").replace(/>/g, "&gt;");
}

or call jQuery $().html() function.

IMHO $text name is little misleading.
Also it's only used with plain text in documentation.
If compatibility is a problem, then we should have $text , $plaintext attributes
instead.

By the way , I forgot to say you, that cell.js is brilliant.
It's simple and powerful at the same time.
Thanks

from cell.

fprijate avatar fprijate commented on June 10, 2024

Typical use of HTML expression in text is:

. . .
$text: "this is  <i> italic </i> text. "
. . .

from cell.

gliechtenstein avatar gliechtenstein commented on June 10, 2024

Wait, I feel like I'm misunderstanding you. Why do you need to this:

<div class='row'>
     &lt; span &gt; test &lt;/span&gt;
</div>

instead of:

<div class='row'>
    <span> test </span>
</div>

from cell.

fprijate avatar fprijate commented on June 10, 2024

We are doing it all the time when we put a program code into some div or pre element
Iwant to do this

{
   $cell: true,
   $type: "pre",
   $text: "this is a span example: <span> test </span>"
}

from cell.

piranna avatar piranna commented on June 10, 2024

Can this be clossed? Seems to be fixed in master...

from cell.

devsnek avatar devsnek commented on June 10, 2024

@fprijate this issue has been addressed in #114

from cell.

gliechtenstein avatar gliechtenstein commented on June 10, 2024

Thanks to @devsnek now we have $html. I wrote a quick demo to test this. It takes a Handlebars template, parses it, and integrates it into Cell. Check it out: https://play.celljs.org/items/1mQfq1/edit

I think this feature is way cooler than I first expected!

from cell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.