Add 'break out' feature #3

Closed
padolsey opened this Issue May 8, 2013 · 12 comments

Projects

None yet

3 participants

@padolsey
Owner
padolsey commented May 8, 2013

Add a syntax that allows you to break out of SIML and simply write regular HTML.

E.g.

div
    ul
        !!!
        <!-- some real html -->
        <li>...</li>
        !!!

Syntax undecided though. Possibly adopt a similar approach to Jade with the pipe.

@wooorm
wooorm commented May 10, 2013

HTML could also be allowed in the heredocs, so authors could write:

div
    ul
        '''
        <!-- some real html -->
        <li>...</li>
        '''

Of course, these strings get auto-escaped, but it would also be possible to differentiate between double and single quoted heredocs (""", '''), where one or the other wouldn’t get escaped?

@padolsey
Owner

Initial implementation done in breakout branch: a0603e8

Not 100% I'm happy with the grave-accent being used as the delimiter but I think I prefer it to '!' or '|'...

So, as it's currently implemented, you can do:

div
    ul
        `
        <!-- Real HTML here -->
        `

A single tick/grave-accent is used to delimit on single or multi-lines.

@padolsey
Owner

@wooorm Currently siml doesn't support heredocs, although that code will work because it's parsed as:

  '' // empty string
  '\n        <!-- some real html -->\n        <li>...</li>        '
  '' // empty string

i.e. the main string surrounded by two empty strings.

Maybe I should add explicit support for ''' and """ though..? That would make it easier to write text without having to escape every quote (`" Blah " blah blah ").

@wooorm
wooorm commented May 11, 2013

Oh right, that’s why those "heredocs" acted so funky :).
And adding these might also be nice to not escape/encode things inside a script, aka, the following SIML...

script
    """
    a > b
    """

…will get converted to:

<script>

    a > b

</script>
@padolsey
Owner

If we add the back-tick for plain unescaped HTML would that solve the <script> issue? So you could just do:

script
    ```
    a > b
    ```
@wooorm
wooorm commented May 11, 2013

Certainly!

@wooorm
wooorm commented May 12, 2013

But…
Would the triple back-tick be a real "heredoc", or, would SIML parse the following unescaped?

script `a > b`
@padolsey
Owner

SIML would parse that as unescaped. The heredoc would just be decorative or useful if you want to include the normal delimiting character in the actual string, e.g.

script
    ```
        // ` ` ` ` `
    ```
@padolsey
Owner

Feature's in master. Bumped to 0.3.3.

@padolsey padolsey closed this May 21, 2013
@Anaphase
Contributor

Can you push 0.3.3 to the npm registry? Currently 0.3.2 is the latest version.

See https://npmjs.org/package/siml

@padolsey
Owner

@Anaphase Sorry about that -- it should be updated now

@Anaphase
Contributor

@padolsey Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment