still-ex / still

A composable Elixir static site generator
https://stillstatic.io
ISC License
252 stars 10 forks source link

Passing variable to templates #189

Open nouun opened 1 year ago

nouun commented 1 year ago

I have a header which I would like to be able to pass a title from the body but I can't figure out a way to accomplish this.

gabrielpoca commented 1 year ago

Hello 👋

You can pass in variables in the third argument. For instance, in your layout:

body
  = include(@env, "header.slime", dark: true)

And then, on the header, you will have the variables @dark and @env[:dark] defined. Is this what you were looking for?