Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 1.39 KB

5.create_new_theme.md

File metadata and controls

47 lines (37 loc) · 1.39 KB

Create new theme

Create new theme

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"

Directory structure

|-- 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

Directory structure explain

  • theme.ex is the place where you define your theme info
  • static directory contain your theme assests
  • template : you put your template files here
  • view: In Phoenix, you can define function in view and use them in template instead of writing too much logic code in the template file.

Naming convention

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.