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

Roc formatting failed #7027

Open
lukewilliamboswell opened this issue Aug 26, 2024 · 1 comment
Open

Roc formatting failed #7027

lukewilliamboswell opened this issue Aug 26, 2024 · 1 comment
Labels
bug Something isn't working formatting

Comments

@lukewilliamboswell
Copy link
Collaborator

Pages.roc-format--failed

## Generated by RTL https://github.com/isaacvando/rtl
module [
    blogPost,
    home,
]

blogPost = \model ->
    [
        """
        <!DOCTYPE html>
        <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>$(model.post.title |> escapeHtml) - Roc Template Example</title>
        </head>
        <body>
            <div>
                <h1>$(model.post.title |> escapeHtml)</h1>
                
        """,
        List.map model.post.content \item ->
            [
                """

                            
                """,
                when item is
                    Text t ->
                        """
                         <p>$(t |> escapeHtml)</p>
                                    
                        """

                    Code c ->
                        """
                         <pre>$(c |> escapeHtml)</pre>
                                    
                        """

                    Image i ->
                        """
                         <img src="$(i |> escapeHtml)" width=100>
                                    
                        """,
                """

                        
                """,
            ]
            |> Str.joinWith ""
        |> Str.joinWith "",
        """

                <br>
                <a href="/">Home</a>
            </div>
        </body>
        </html>

        """,
    ]
    |> Str.joinWith ""

home = \model ->
    [
        """
        <!DOCTYPE html>
        <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Roc Template Example Blog</title>
        </head>
        <body>
            <div>
                <h1>Posts</h1>
                <ul>
                
        """,
        List.map model.posts \post ->
            """

                        <li>
                            <a href="/posts/$(post.slug |> escapeHtml)">$(post.title |> escapeHtml)</a>
                        </li>
                    
            """
        |> Str.joinWith "",
        """

                </ul>
            </div>
        </body>
        </html>

        """,
    ]
    |> Str.joinWith ""

escapeHtml : Str -> Str
escapeHtml = \input ->
    input
    |> Str.replaceEach "&" "&amp;"
    |> Str.replaceEach "<" "&lt;"
    |> Str.replaceEach ">" "&gt;"
    |> Str.replaceEach "\"" "&quot;"
    |> Str.replaceEach "'" "&#39;"
@lukewilliamboswell lukewilliamboswell added bug Something isn't working formatting labels Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatting
Projects
None yet
Development

No branches or pull requests

2 participants
@lukewilliamboswell and others