-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Syntax for <template> variables #4219
Comments
@indolering IMHO I feel the Again I feel should be a ❓ not ❌ . Your thoughts? |
Not that anyone would write an element And HTML5 allows any character to be used as identifier / fragment id as they can be Overall no real interpretational threat but does introduce possibility of navigational issues arising due to fragment identifiers. |
Inline styling is a thing, when I was working on web components it was much easier to have the styles embedded within the component itself instead of in a separate document. AFAIK this syntax is already considered a mistake by the JSX community. Maintainers can override if they wish. |
Escaping is a PITA, let's not do that! |
I'm leaning towards having multiple tags to replicate EJS's control flow, escaping, and whitespace elimination features. I would be more partial to |
I agree with @snuggs, Note: we do not allow variables inside the style tag, they have few ways to deal with this. |
@caridy we just barf on anything non-alphanumeric (inclusive of We came up with an implementation a while ago and has been working smoothly aligning to most (not all) needs for the past couple of years. I just love when can actually write HTML in the browser. (Not a permutation of XML in JavaScript...that needs endless packages to get to a screen 😳. Which is why we are all here 😄 ) |
Do you mean your specific templating system or the template proposal? |
@indolering our abstraction layer on top of the template proposal, which adds a bunch of restrictions for various reasons. |
@caridy just had an epiphany dealing with the
Like I said before a few years ago we skipped over |
TRUE...However even after a couple years i've still yet to see an "inline style" (via Perhaps this is the "JSX is broken" you were speaking of. I do recall some curlybrace style in JSX attributes but I've refused to use JSX for years now as it will probably deprecate itself before the platform does. It's not HTML, nor CSS, nor JS no matter how many backticks and parenthesis are used. And for that reason cues should be taken from JSX but should bend to the platform and not the inverse IMHO. /cc @caridy |
An idea for an HTML-esque approach: use an element for node slots and attribute namespace for attribute slots. Let's say the name for the element and attribute namespace would be Example usage: <form bind:action="variableName=/default-value" method="post">
<bind var="variableName"/>
<input type="text" name="fullname" bind:placeholder="variableName">
<input type="email" name="email" bind:placeholder="variableName=Default placeholder value">
<button>
<bind var="variableName">Default content</bind>
</button>
</form> The obvious downsides of this are verbosity, no support for setting only a part of attribute's value without introducing another interpolation syntax and that it's unclear if I'm not saying this a great idea, just something that might work safely and be viable, so I thought I might share it here. Edit: Some, but slight, changes to the HTML parser would be needed, that is allowing |
@jurca Wouldn't this break HTML validation? |
I think it would - the introduction of a new element would already do it, I think. At least the W3 validator rejects the following input: <!DOCTYPE html>
<html lang="en">
<head><title>Title</title></head>
<body>
<bind var="variableName"/>
</body>
</html> The standard would need to be extended, and validators updated - but that would be the case for any syntax using the |
This is a bikeshed ticket to opine the best syntax for
<template>
variables.{}
<template><style>x-foo {color: blue;}</style>
.{{}}
${}
@{}
at-rules
.#{}
<a href=faq.html#{...}>
<% %>
<% >
<< >>
<$ >
<= >
<# >
<! >
<_ _>
<__ __>
The text was updated successfully, but these errors were encountered: