htmlx-org / HTMLx

One Template to rule them all
588 stars 9 forks source link

Proposal: Wrapping Tag `<htmlx></htmlx>` and Tag based control flow #9

Closed IamManchanda closed 6 years ago

IamManchanda commented 6 years ago

{{ If JavaScript will be the one to handle browser based compilation/rendering at last to the browser the why not }}

These are 2 Proposals here:

  1. Wrapping Tag <htmlx></htmlx> Reasoning: This denotes that though file extension is .html but is a document that is html with some better eXtensions

  2. Tag based control flow Reasoning: Better syntax highlighting and Emmet support for normal .html extension without any plugin (as seen in screenshots)


screen shot 2018-05-03 at 7 18 36 pm
screen shot 2018-05-03 at 7 19 26 pm
IamManchanda commented 6 years ago

cc @Rich-Harris @developit

arxpoetica commented 6 years ago

This is interesting, but likely unnecessary since most components or templates are scoped to other containing elements. That is, <xhtml/> might just be cruft.

On the other hand, maybe there's a standalone case where this makes sense?

IamManchanda commented 6 years ago

That is, <xhtml/> might just be cruft.

Don't know ... maybe template here makes more sense then <htmlx />


That being said on control flow stuff

@arxpoetica I am giving my viewpoint as html user ... a web framework user I don't have enough knowledge (as of yet) whether this will work or not by compiling or not

But I think <x-each>, <x-if>, etc can be great for control flow without syntax highlighting issues and good default emmet support when we talk as user point of view

Rich-Harris commented 6 years ago

We experimented with this idea when discussing the syntax for Svelte v2 and concluded that using elements for control flow is a bad idea. For one thing, it's much harder to discern the structure of a component at a glance when everything is angle brackets. For another, there's no way to express the concept of a sub-clause with tags:

{#if foo}
  <p>foo is true</p>
{:else}
  <p>foo is false</p>
{/if}

<!-- becomes... -->
<x-if condition='foo'>
  <p>foo is true</p>

  <x-else>
    <p>foo is false</p>
  </x-else>
</x-if>

That's confusing; it's also a lot more to type.

I'm not sure I see any benefit to wrapping everything in an <htmlx> tag. It's just extra indentation for the sake of it. A <template> element would at least be semantically correct. Either way, I would argue that's the concern of the framework, rather than HTMLx itself.

IamManchanda commented 6 years ago

I think you are right... Closing this