Skip to content

Commit eacf7ef

Browse files
committed
Update README.md
1 parent 934aa22 commit eacf7ef

1 file changed

Lines changed: 49 additions & 3 deletions

File tree

README.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ In this folder are located files related to our application building. That can b
161161
Compiled state of our app with processed styles, templates, scripts and assets.
162162

163163
**Warning! Never work inside this folder, because your changes would be overwritten on every build**
164-
164+
pu
165165

166166
## File Types
167167

@@ -171,7 +171,7 @@ Our app consists of different file types.
171171

172172
We use [SASS](http://sass-lang.com/) as CSS preprocessor language.
173173
Main variables are defined in ```src/_variables.scss``` folder.
174-
For making life easier we broke down styles into components, and on build we're just merging all ```.scss``` files together and processing it to ```pubilc/css/app.css``` file. Style files are merged in following order
174+
For making life easier we broke down styles into components, and on build we're just merging all ```.scss``` files together and processing it to ```dist/css/app.css``` file. Style files are merged in following order
175175

176176
```
177177
{variables.scss}
@@ -185,13 +185,59 @@ There are also different theme variations located in ```src/_themes/``` folder,
185185

186186
#### Scripts (*.js)
187187

188+
We separate application's scripts across it's components. For simplicity we use ES5 in this version and just wrap each component's script in jQuery ```$(function() { })```. JS configurations are defined in ```src/config.js``` file. On build application script files are merged together and copied to ```dist/js/app.js``` fole. Script files are merged in following order
189+
190+
```
191+
{config.js}
192+
{all .js files except main.js}
193+
{main.js}
194+
```
195+
188196
#### Templates (*.hbs)
189197

198+
Templates are pieces of HTML files written in template engine language. We use [Handlebars](http://handlebarsjs.com/), which allows to have conditions in HTML, reuse partials in different pages (e.g. sidebars, footers), use loops, layouts etc.
199+
190200
#### Pages (*-page.hbs)
191201

202+
Templates themselves are just parts of markup, and aren't compiled as separate files. What we really want in final output is ```.html``` page in ```dist/``` folder. For that reason there are special handlebar templates which filenames end with ```-page.hbs```. Each ```{pagename}-page.hbs``` file would be compiled to ```dist/{pagename}.html``` page with flatened file structure.
203+
204+
Pages can consist of different templates (partials) which can be included thanks to handlebars partial including. Also each page have it's context which is data passed into template on rendering. That data is used in template expressions and variables. page contexts can be defined in two ways:
205+
206+
**YAML** headers ([example](https://github.com/modularcode/modular-admin-html/blob/master/src/app/dashboard/index-page.hbs))
207+
208+
```
209+
---
210+
foo: bar
211+
list:
212+
- One
213+
- Two
214+
- Three
215+
---
216+
```
217+
and **_context.js** files ([example](https://github.com/modularcode/modular-admin-html/blob/master/src/_context.js)).
218+
```
219+
module.exports = {
220+
foo: 'bar',
221+
foo2: function() {
222+
// do some magic, return some string
223+
},
224+
list: [
225+
'One', 'Two', 'Three'
226+
]
227+
}
228+
```
229+
230+
The final result of page context is compination of both ways. Moreover, different depth level _context.js files are extending each other and then are extended with YAML headers data. In our case we have ```src/_context.js``` file, where main website properties are defined and YAML headers in ```*-page.hbs``` files.
231+
192232
#### Layouts (*-layout.hbs)
193233

194-
#### Contexts (_context.js)
234+
If different pages have lot of common components like sidebar, header, footer, It's a good idea to define a layout for those common pages and define in page files only the content which is unique. Layout is a page content wrapper. If the page has layout in output we'll get page's content inserted into layout. Layouts should have ```{{{body}}}``` handlebars tag, which is entry point for page content.
235+
236+
If you need more advanced layouting you can use [handlebar-layouts](https://www.npmjs.com/package/handlebars-layouts) helper approach, which is also available out of the box.
237+
238+
#### Vendor files
239+
240+
Except application files there are also third party plugin files (e.g. Bootstrap). They are managed by using [Bower](http://bower.io/). Usually vendor libraries consist from scripts, styles and assets (images, fonts). The build system will concatenate and copy all script and style files correspondingally to ```dist/js/vendor.js```and ```dist/css/vendor.css``` also will copy all assets to ```dist/assets/``` folder.
195241

196242
## Build Tasks
197243

0 commit comments

Comments
 (0)