Re: Overload str.replace to take a Map?

2018-05-20 Thread Bob Myers
I'm not a huge fan of this idea, but just as a reference point, here is a routine to convert a string to using smart quotes: ```js // Change straight quotes to curly and double hyphens to em-dashes etc. export function smarten(a: string) { if (!a) return a; a =

Re: Re: Proposal: Phase-Invariant Einno Soliton Templates

2018-05-20 Thread Abdul Shabazz
I am not an academic troll: i am actually underemployed at the monent; i enjoy the labor very much, as well as the people i work with. -- Abdul S. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Overload str.replace to take a Map?

2018-05-20 Thread Isiah Meadows
I was using HTML primitive escaping as a concrete example, but there's others. Most use cases in my experience are essentially escaping for various reasons, but it's also useful for simple extensible templating where you control the expansion, but not the source. Here's a concrete example of what

Re: Overload str.replace to take a Map?

2018-05-20 Thread Jordan Harband
Something that escapes HTML wouldn't belong in the language, it would belong in browsers (the HTML spec, probably). This list is for language-level proposals, so I don't think this is the right list to suggest it. Are there use cases for things in this thread that aren't browser-specific? On

Re: Overload str.replace to take a Map?

2018-05-20 Thread Isiah Meadows
Next challenge: how does it compare to these two? ```js // Simplified version function simpleEscape(text) { return text.replace(/<(?:\/?script)?||>||/gu, m => { switch (m) { case '<': return '[lt]', case '': return '[lt]', case '>': return '[gt]', case '': return '[gt]',

Re: Proposal: Phase-Invariant Einno Soliton Templates

2018-05-20 Thread Michael Luder-Rosefield
I've been suspecting along similar lines, but was reticent to make any outright accusations. On Mon, 21 May 2018, 00:41 Sanford Whiteman, < swhitemanlistens-softw...@figureone.com> wrote: > > I personally would prefer that these proposals are specified in terms > > of *what's actually being

Re: Proposal: Phase-Invariant Einno Soliton Templates

2018-05-20 Thread Sanford Whiteman
> I personally would prefer that these proposals are specified in terms > of *what's actually being proposed* I think what's actually being proposed is that we fall for a troll. Possibly an academic troll who will later ridicule its victims, viz. the Social Text scandal

Re: Proposal: Phase-Invariant Einno Soliton Templates

2018-05-20 Thread Isiah Meadows
I personally would prefer that these proposals are specified in terms of *what's actually being proposed*, rather than in terms of some very elaborate analogy. Symbolic analogies to other tangentially related fields work for teaching existing concepts to intuitive people, but not for drafting and

Re: Overload str.replace to take a Map?

2018-05-20 Thread kai zhu
hi mathias, i see... here's some simple, throwaway glue-code that does what i think you want. ```js /*jslint node: true */ 'use strict'; var text; text =

Re: Overload str.replace to take a Map?

2018-05-20 Thread Mathias Bynens
This particular `escapeHtml` implementation is limited to replacing single characters, but if you wanted to escape any characters that can be represented using a named character reference, you’re gonna need something more generic, as some named character references expand to multiple characters.

Re: Overload str.replace to take a Map?

2018-05-20 Thread kai zhu
sorry, there was a bug in the standalone-solution i last posted. here’s corrected version ^^;;; also highlighted in blue, the escapeHTML part of code relevant to this discussion. and honestly, replacing those 6 blue-lines-of-code in this real-world example, with the proposed map-replace

Re: Proposal: Phase-Invariant Einno Soliton Templates

2018-05-20 Thread Michael Luder-Rosefield
At this point I fully expect Abdul to describe the Norse, Greek and Hindu pantheons in terms of turbulence physics and give a few pseudocode JS snippets indicating that they can also be used to handle REST requests. And all in 3 short sentences. On Sun, 20 May 2018 at 02:49 kdex

Re: "Stupid" JSON Number Serialization Question

2018-05-20 Thread Richard Gibson
That seems like a question best addressed by something like JSON Schema. ECMAScript is not unique in lacking sufficient native machinery to process JSON numbers that have no IEEE 754 64-bit representation, and similar issues exist for binary data and complex types like date/time values. On

Re: Overload str.replace to take a Map?

2018-05-20 Thread Isiah Meadows
@Mathias My partcular `escapeHTML` example *could* be written like that (and it *is* somewhat in the prose). But you're right that in the prose, I did bring up the potential for things like `str.replace({cheese: "cake", ham: "eggs"})`. @Kai Have you ever tried writing an HTML template system on