angular-macros

An AngularJS module that allows for macro definition and invocation. Can be used to form the basis for website templating in a purely Angular way.

Added by: Sam Deering

GitHub

Repository

debonet/angular-macros

Stats

Stars: 2

Watchers: 2

Forks: 2

Module Description

angularjs-macros

An AngularJS module that allows for on-the-fly macro definition and use within HTML

How to use

Just include modMacros in your main application, e.g.:

angular.module('myApp',['modMacros', ...]);

Macro Definition

<define macro="'example'">
    this is a simple example of a macro
    
        substitutions: {{variable1}}, {{variable2}}
        
        and inner content: {{content}}
        
        and content subselection: {{content|find:b}}

</define>

Macro Invocation

<invoke macro="'example'" variable1="foo" variable2="bar">
    THIS IS {{dynamic}} AND <B>BOLD STUFF</B> 
</invoke>

Simple website template

page.macro:

<define macro="'page'">
    <html>
        <head>
            <title>{{title}}</title>
        </head>
        <body>
            <h1>Standard page header</h1>
            <h2>{{title}}</h1>
            <div class='content'>
                {{content}}
            </div>
            <div class='copyright'>Copyright (c) 2012 {{author}}</div>
        </body>
    </html>
</define>

then in index.html:

<ng-include src="'page.macro'" />

<invoke macro="'page'" title="some page" author="me">
  This is some little page. 
</invoke>

Module stats last updated: 2015-06-04 11:09:20

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!