module Motion::HTML::Assignable

Direct including types

Defined in:

motion/html/assignable.cr

Macro Summary

Macro Detail

macro props(*type_declarations) #

Declare what a page needs in order to be initialized.

This will declare an instance variable and getter automatically. It will also add arguments to an initialize method at the end of compilation.

Examples

class Users::IndexPage < MainLayout
  # This page needs a `User` or it will fail to compile
  # You can access it with `@user` or the getter method `user`
  needs user : User

  # This page can take an optional `ProductQuery`. This means you can
  # Leave `products` off when rendering from an Action.
  needs products : ProductQuery?

  # When using a `Bool` Lucky will generate a method ending with `?`
  # So in this case you can call `should_show_sidebar?` in the page.
  needs should_show_sidebar : Bool = true
end

[View source]