Giter VIP home page Giter VIP logo

ember-cli-content-for-config's Introduction

Ember-cli-content-for-config

This addon allows you to use the {{content-for 'config.path.to.value'}} helper in your app/index.html file to interoplate values from the config/enviroment.js config object into the index.html file.

This is useful if you need to include different config values in your index.html file based on the build enviroment.

Installation

  • ember install ember-cli-content-for-config

Usage

First set any values you may wish to display on the config object in config/enviroment.js:

/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    title: 'My Sweet App',
    description: 'This app is sweet',
    version: require('../package.json').version,
    analytics: {
      google_analytics_id: 'UA-abc123-x',
    },
    modulePrefix: 'my-sweet-app',
    environment: environment,
    // ...
    },
  // ...

  return ENV;
};

Then you can reference the config values in your app/index.html with content-for using the key config. followed by the path to the property. For example, to interpolate the version you would use {{content-for 'config.version'}}.

<!DOCTYPE html>
<html class="{{content-for 'config.environment'}}">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{{content-for 'config.title'}}</title>
    <meta name="description" content="{{content-for 'config.description'}}">
    <meta name="version" content="{{content-for 'config.version'}}">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    {{content-for 'head'}}

    <link rel="stylesheet" href="assets/vendor.css">
    <link rel="stylesheet" href="assets/my-sweet-app.css">

    {{content-for 'head-footer'}}
  </head>
  <body>
    {{content-for 'body'}}

    <script src="assets/vendor.js"></script>
    <script src="assets/my-sweet-app.js"></script>
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

      ga('create', '{{content-for 'config.analytics.google_analytics_id'}}', 'auto');
      ga('send', 'pageview');
    </script>

    {{content-for 'body-footer'}}
  </body>
</html>

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

ember-cli-content-for-config's People

Contributors

bmac avatar krasnoukhov avatar ilkkao avatar rmachielse avatar ember-tomster avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.