3 ms·
Cool to see you jump in, Ian. I don't particularly mind the prefix thing. It came up in the PEP discussion, as did choice of backticks to indicate this is diff
by pauleveritt 2y ago
Cool to see you jump in, Ian.
I don't particularly mind the prefix thing. It came up in the PEP discussion, as did choice of backticks to indicate this is different. But JS template literals -> tagged template literals shows, you can get from A to B without a fundamental change.
I'm very interested though in the deferred part. I agree that there is complexity. I weigh that, though, against the complexity of existing Python HTML templating, where finding out what just happened is...harder.
I think we can get a TSX-level of DX out of this. And maybe a Lit level of composition. Agree that it is non-zero complexity.
- ianbicking 2y agoHey Paul! I think JSX is an example of the somewhat crude but practical use of simple execution patterns. For instance if you have a loop you do: return <ol> {items.map((item, i) => <li key={i}>{item}</li>)} </ol>; Which isn't really templating at all, but just the ability to use inline expressions and easily construct objects does get the job done. Or in a SQL builder with JavaScript tagged templates, I do: exec(sql` SELECT * FROM a_table WHERE category = ${category} ${subcategory ? sql`AND subcategory=${subcategory}` : sql``} `) That is, I nest tagged templates to handle different logic conditions and loops. If there's deferred execution, it's done with ?: and .map() – though these very long expressions don't work nearly as well in Python. (List comprehension is in some ways better than .map()/.filter(), but not for very large expressions like in a JSX template.)