Skip to content

Allows you to store simple, interpolatable message templates like how it's done in Rails

License

Notifications You must be signed in to change notification settings

garbles/angular-gs-simple-messages

Repository files navigation

angular-gs-simple-messages

Build Status

Allows you store simple, interpolatable message templates in a single place like done in Rails with the t helper.

NOTE: This plugin depends on lodash

Installing

bower install angular-gs-simple-messages

Using

Include the package in your application:

var app = angular.module('app', ['gs.simple-messages']);

Create a value object to store your templates:

app.value('templates', {
  gabe: {
    is: {
      the: {
        best: 'HELLO {{ name }}'
      }
    }
  }
})

Set the templates module as part of your configuration:

app.config(function (messagesProvider) {
  messagesProvider.setTemplates('templates');
})

Use it like so:

app.controller('SomeCtrl', function (messages) {
  messages('gabe.is.the.best', { name: 'GABE!' }); // => "HELLO GABE!"
  messages('gabe.is.the', { name: 'GABE!' }); // => throws error
});

About

Allows you to store simple, interpolatable message templates like how it's done in Rails

Resources

License

Stars

Watchers

Forks

Packages

No packages published