OneScript icon indicating copy to clipboard operation
OneScript copied to clipboard

hello world

Open Mouvedia opened this issue 10 years ago • 0 comments

Concerning your hello world

<!doctype html>
<html> {
    <head> {
        <title>Hello from OneScript</title>
    }
    <body> {
      <h1>Hello from OneScript</h1>
      <h3>Let's count some numbers<h3>
      <ul> {
          defaultColor = 'blue'

          this.each([1, 2, 3, 5]);

          <css> {
              font-weight: bold;
              color: ${defaultColor};

              li:nth-child(even) {
                  color: yellow;
              }
          }

          <li>${this}</li>
      }
    }
}

couldn't we have

<!doctype html>
<html>
    <head>
        <title>Hello from OneScript</title>
    <body>
      <h1>Hello from OneScript</h1>
      <h3>Let's count some numbers</h3>
      <ul>
      {
          defaultColor = 'blue'
          this.each([1, 2, 3, 5]);

          <css>
              font-weight: bold;
              color: ${defaultColor};

              li:nth-child(even) {
                  color: yellow;
              }
          </css>

          <li>${this}</li>
      }
      </ul>
    </body>
</html>

instead?

It would keep the usage of unnecessary curly braces to a minimum. And permits stuff like that

<div>
  text1
  {
  //js that generates text2
  }
</div>

more easily by allowing the concatenation of text nodes and js output. It's also more readable but that's subjective.

PS: there's a typo in your example with the closing h3 tag

Mouvedia avatar Jul 05 '15 14:07 Mouvedia