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

That looks a lot like ructe [0], a templating language that I really love. It compiles templates to functions that you can call from Rust using a build script. The functions parameters are accessible from your templates. You can even import and run arbitrary rust code from your app:

    @use any::rust::Type;
    @use super::statics::style_css;
    
    @(name: &str, items: &[Type])
    
    <html>
       <head>
         <title>@name</title>
         <link rel="stylesheet" href="/static/@style_css.name" type="text/css"/>
       </head>
       <body>
         <h1>@name</h1>
         <dl>
         @for item in items {
           <dt>@item.title()</dt>
           <dd>@item.description()</dd>
         }
         </dl>
       <body>
    </html>

[0]: https://github.com/kaj/ructe


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

Search: