Chubi
is shipped with a mix tast to generate a new theme
mix chubi.new.theme <theme_name>
theme_name must be in lower case and must not contains white space Generated theme is located at "lib/chubi_web/theme"
|-- theme.ex
|-- static/
|-- templates/
| |-- layout/
| |-- partial/
| |-- shortcode/
| |-- page/
| |-- post/
| |-- category/
| |-- tag/
|-- views/
|-- layout_view.ex
|-- partial_view.ex
|-- shortcode_view.ex
|-- page_view.ex
|-- post_view.ex
|-- category_view.ex
|-- tag_view.ex
theme.ex
is the place where you define your theme infostatic
directory contain your theme asseststemplate
: you put your template files hereview
: In Phoenix, you can define function in view and use them in template instead of writing too much logic code in the template file.
Phoenix
apply a strict rule for naming file and directory that you have to follow when create a new one.
There is one _view.ex
file for each directory in templates
directory. For example: you create a directory name test
in template
directory, you have to create a view name test_view.ex
in views
directory. And all functions which is defined in test_view.ex
can be used directly in any template file that is put in test
directory.