Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'break out' feature #3

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

Add 'break out' feature #3

padolsey opened this issue May 8, 2013 · 12 comments

Comments

@padolsey
Copy link
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
Copy link

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
Copy link
Owner Author

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
Copy link
Owner Author

@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
Copy link

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
Copy link
Owner Author

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
Copy link

wooorm commented May 11, 2013

Certainly!

@wooorm
Copy link

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
Copy link
Owner Author

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
Copy link
Owner Author

Feature's in master. Bumped to 0.3.3.

@Anaphase
Copy link
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
Copy link
Owner Author

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

@Anaphase
Copy link
Contributor

@padolsey Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants