-
Create a new helper method which can be used in all view file. For now, i am doing like this:
abstract class BaseLayout
include Lucky::HTMLPage
def render
content
end
private def helper_foo
# ...
end
end Then inherit all others page from it. abstract class AuthLayout < BaseLayout
# ...
end abstract class MainLayout < BaseLayout
# ...
end I have to change src/app.cr to # ...
+ require "./pages/base_layout"
require "./pages/**" Then, i can use helper_foo every where as expected. My question is, is this the expected usage? If is is yes, should we create Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You could either put this in abstract class BaseLayout
include Lucky::HTMLPage
include PageHelpers
def render
content
end
end
# src/pages/mixins
module PageHelpers
def helper_foo
end
end Just be sure to require the new folder before your layouts. |
Beta Was this translation helpful? Give feedback.
You could either put this in
src/components/shared
or make asrc/pages/mixins
.Just be sure to require the new folder before your layouts.