Skip to content

Latest commit

 

History

History
109 lines (93 loc) · 2.12 KB

README.md

File metadata and controls

109 lines (93 loc) · 2.12 KB

Ember-index

npm version Build Status Ember Observer Score

Ember addon for manipulating index.html

Why use it?

Ember cli is doing a great job at generating static assets including index.html. But sometimes you wish to generate an enhanced index file which is actually a server-page (JSP, PHP etc.).
In order to do so, you will need to include specific code blocks in the generated server-page, which won't be included in the generated index.html (and vice versa).
This simple addon is meant for doing exactly this.

Installation

  • npm i ember-index --save-dev

##Usage

The following code:

// config/enironment.js

module.exports = function(environment) {
  var ENV = {
    //...

    'ember-index': {
      output: 'index.jsp',
      destDir: 'export', // Optional (default: '.')
      content: [{
        key: '1',
        file: 'example1.txt',
        includeInIndexHtml: true,
        includeInOutput: false,
      },{
        key: '2',
        string: 'My Text',
        includeInIndexHtml: false,
        includeInOutput: true,
      }]
    }
  };

  //...

  return ENV;
};
// app/example1.txt
<meta content="Example 1">
// app/example2.txt
<meta content="Example 2">
<!-- app/index.html -->
<!DOCTYPE html>
<html>
  <head>
     ...
     {{content-for 'ember-index-1'}}
     {{content-for 'ember-index-2'}}
  </head>
  <body>
      ...
  </body>
</html>

Will result

<!-- dist/index.html -->

<!DOCTYPE html>
<html>
  <head>
    <meta content="Example 1">
    ...
  </head>
  <body>
    ...
  </body>
</html>
<!-- dist/export/index.jsp -->
<!DOCTYPE html>
<html>
  <head>
    <meta content="Example 2">
    ...
  </head>
  <body>
    ...
  </body>
</html>

Tests

npm run test

License

MIT