diff --git a/CHANGELOG.md b/CHANGELOG.md index 9870d9c..d65a3fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +### Feature + +- Add template partial + - A partial is a template whose name starts by “_”. It won't be rendered directly (so it doesn't need meta like “prismic-api”) but is included in other +templates using the helper `partial`. (`[%- partial('footer') %]` will include +the partial “_footer.html.erb”) +- Add helper to change ref +- Add OAuth2 authentication +- Use [EJS](https://github.com/visionmedia/ejs) for template rendering + - Its HTML escaping and filters are available + +### Incompatible changes + +- Because EJS is now used, every template returning HTML have to be fixed +(by replacing `[%= ... %]` by `[%- ... %]`) in order to stop escaping the HTML +twice. + ## 0.0.4 ### Feature diff --git a/README.md b/README.md index a5fbda2..90b093d 100644 --- a/README.md +++ b/README.md @@ -179,9 +179,12 @@ It is possible to customize the URL as well. To do so, just add a `` tag ## Internals -baked.js is built on top of [Node.js](nodejs.org) and use [dom.js](https://github.com/andreasgal/dom.js/) to emulate the DOM. +baked.js is built on top of [Node.js](nodejs.org). -It uses [Q](https://github.com/kriskowal/q) and [lodash](http://lodash.com), and let [Gulp](gulpjs.com) and [browserify](browserify.org) handle the generation of the browser library. +It uses [Q](https://github.com/kriskowal/q) and [lodash](http://lodash.com), +let [Gulp](gulpjs.com) and [browserify](browserify.org) handle the generation +of the browser library and uses [EJS](https://github.com/visionmedia/ejs) for +the template rendering. ### Dynamic browser mode @@ -192,7 +195,7 @@ The generation can actually be performed at 2 places: - It allows to send proper content the browsers and search engines. - Dynamically by the browser - Every statically rendered page is able to re-generate itself, and then to emulate the navigation in the others pages (using [HTML5's History API](http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-history-interface)). - - It allows to specify specific `access_token` and `ref`, in order to render the content using a specific prismic.io's release. + - It allows to specify specific `access_token` and `ref`, in order to render the content using a specific prismic.io's release. These can be set automatically using the [OAuth2 authentication](#auth2-authentication). The dynamic mode needs some specific components: @@ -204,10 +207,59 @@ The dynamic mode needs some specific components: - find the template to use, its parameters and the given argument in case of non-statically-rendered page (routing) - This case can happen when loading a page that is created only with a specific release. -## Notes +#### Specific ref to use -- the server build a DOM structure (using JSDOM) in order to navigate inside it, so: - - The tags `<% %>` can't be used, because JSDOM doesn't like them +baked.js provides a helper to easilly switch between refs. + +It listen changes made on elements containing the attribute +“`data-prismic-action="update"`” and update the ref (and re-generate) +accordingly. + +Here an example of use: + +```ejs + +``` + +#### OAuth2 authentication + +baked.js provides a helper to authenticate to your prismic.io application +using OAuth2. + +It listen the “click” events on elements containing attributes +“`data-prismic-action="signout"`” or “`data-prismic-action="signin"`.” + +In order to work, this feature needs a meta tag “`prismic-oauth-client-id`” +to be defined. + +Here an example: + +```ejs + +... +[% if (loggedIn) { %] + + +[% } else { %] + +[% } %] +``` ### Licence diff --git a/example/to_generate/_footer.html b/example/to_generate/_footer.html new file mode 100644 index 0000000..d3d4c46 --- /dev/null +++ b/example/to_generate/_footer.html @@ -0,0 +1,18 @@ +
+ ++ [% if (loggedIn) { %] + + + [% } else { %] + + [% } %] +
diff --git a/example/to_generate/blog/index.html b/example/to_generate/blog/index.html index ad1144c..cc25975 100644 --- a/example/to_generate/blog/index.html +++ b/example/to_generate/blog/index.html @@ -7,6 +7,7 @@ + @@ -36,7 +37,7 @@