Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Most template languages can't do something like that:

  // data
  const numbered = true // or false
  const strings = ["a", "b", "c"]

  // render
  const items = strings.map(i => <li key={i}>Item {i}</li>)

  if (numbered)
    return (<ol>{items}</ol>)
  else
    return (<ul>{items}</ul>)


Marko can! It's "define" tag lets you create reusable templates in your reusable templates.

https://markojs.com/docs/reference/core-tag#define


RippleJS is doing the same sort of thing, but better IMO




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: