What is the intuition behind "expand"? What is being expanded, and what is it expanding into?
On Tue, Dec 11, 2018 at 10:59 PM Isiah Meadows <[email protected]> wrote: > Those names a little too generic for my liking here. What about > `String.expand(template, ...params)`? > > And also, let's not try to bake a traditional template engine into the > JS spec - syntactic template strings already work well enough. > > ----- > > Isiah Meadows > [email protected] > www.isiahmeadows.com > > On Wed, Dec 12, 2018 at 1:13 AM Michael Luder-Rosefield > <[email protected]> wrote: > > > > Why not String.tag or .tagged? > > > > While we're at it, is there any good reason not to have something like > this: > > > > ``` > > String.template = (template : String, > taggerFn=String.identity/tag/tagged : Function) => (keys : Array | Object) > => taggerFn(template, (keys is Array) ? ...keys : keys) > > // apologies for pseudo-semi-functional code > > // having keys be an object allows template to be filled by key name > rather than just index > > ``` > > This would make templates closer to the traditional usage, where the > template comes first and is later passed values to be filled in with. > Having the taggerFn as an argument allows for things like Isiah's > escape-then-apply tagging examples. > > > > > > On Wed, 12 Dec 2018 at 12:51 Isiah Meadows <[email protected]> > wrote: > >> > >> I'm not married to `identity`, and I agree the name is probably not > >> ideal. I'm more concerned about functionality, though. > >> > >> ----- > >> > >> Isiah Meadows > >> [email protected] > >> www.isiahmeadows.com > >> > >> On Tue, Dec 11, 2018 at 5:41 AM T.J. Crowder > >> <[email protected]> wrote: > >> > > >> > On Mon, Dec 10, 2018 at 7:08 PM Isiah Meadows > >> > <[email protected]> wrote: > >> > > > >> > > It'd be *way* easier to construct simple template tags if there was > a > >> > > built-in identity tag > >> > > >> > Wholeheartedly agree, a couple of months ago I considered posting > something very similar, both for utility reasons and in hopes that it would > be an optimization target (being a standard operation). > >> > > >> > I find the name `identity` unilluminating, though, partially because > it's not quite the same meaning as the usual "identity" function (`function > identity(x) { return x; }`), though it's close. `assemble`? > >> > > >> > -- T.J. Crowder > >> _______________________________________________ > >> es-discuss mailing list > >> [email protected] > >> https://mail.mozilla.org/listinfo/es-discuss > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

