You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-3Lines changed: 49 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,7 +161,7 @@ In this folder are located files related to our application building. That can b
161
161
Compiled state of our app with processed styles, templates, scripts and assets.
162
162
163
163
**Warning! Never work inside this folder, because your changes would be overwritten on every build**
164
-
164
+
pu
165
165
166
166
## File Types
167
167
@@ -171,7 +171,7 @@ Our app consists of different file types.
171
171
172
172
We use [SASS](http://sass-lang.com/) as CSS preprocessor language.
173
173
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
175
175
176
176
```
177
177
{variables.scss}
@@ -185,13 +185,59 @@ There are also different theme variations located in ```src/_themes/``` folder,
185
185
186
186
#### Scripts (*.js)
187
187
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
+
188
196
#### Templates (*.hbs)
189
197
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
+
190
200
#### Pages (*-page.hbs)
191
201
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:
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
+
192
232
#### Layouts (*-layout.hbs)
193
233
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.
0 commit comments