sailfish icon indicating copy to clipboard operation
sailfish copied to clipboard

RFC 4: Compile time evaluation

Open Kogia-sima opened this issue 5 years ago • 0 comments

Description

Evaluate buffer block (<%= %>) at compile time, inspired by Zapper.

Example

template:

<html>
  <head>
    <title><%= title %></title>
  </head>
  <body>
    <%= content %>
  </body>
</html>
#[derive(TemplateOnce)]
#[template(path = "...")]
#[template(eval(title = "Home"))]
pub struct Home {
    content: String
}

Then title is evaluated at compile time. Note that since title must be escaped at compile time, users must pass value as literal

Kogia-sima avatar Jun 17 '20 14:06 Kogia-sima