angular-snippets
Angular directives to display code with.
- Use Prism syntax highlighter
- Support theme
Example
<snippets path="snippets/demo" files="['index.html', 'app.js', 'missing.css']">
<snippets-pane snippet="{name: 'run', icon: 'fa-cog'}">
<iframe src="snippets/demo/index.html"></iframe>
</snippets-pane>
</snippets>
Getting started
Dependencies
Installation
You can either download the latest version on the github repository or use Bower to install it automatically:bower install angular-snippets
Bower will also install its dependencies.
Load the packages into your HTML page:
<link rel="stylesheet" type="text/css" href="path/to/prism/prism.css">
<script src="path/to/prism/prism.js"></script>
<script src="path/to/angular-snippets.min.js"></script>
Snippets need one theme, you can use one of the official themes or create your own. Load the theme:
<link rel="stylesheet" type="text/css" href="path/to/themes/bootstrap-tabs/style.css">
<script src="path/to/themes/bootstrap-tabs/theme.js"></script>
Utilisation
Dependency
Add into your application definition, the module and the theme dependencies:angular.module('MyApp', ['Snippets', 'SnippetsThemeBootstrapTabs']);
Usage
This module can either use a file list from the attribute files or download a manifest (default is manifest.json) and use its files property.
Both may depends on a path attribute.
File list
<snippets path="snippets/" files="['index.html', 'app.js']"></snippets>
Manifest
<snippets path="snippets/"></snippets>
width manifest.json:
{
"files": [
"index.html",
"app.js"
]
}
API
Provider
snippetsProvider
snippetsProvider allows to configure the module by extending default options and providing content to append.function (option:ModuleOptions)
The manifest have to include a main key files as an array of string.
Basically, used to define the directive template property by the themes.
function (element: angular.element)
Return: None
function (extension: String)
Return: String
function (template: String)
Return None
function (template: String)
Return None
Directives
snippets
Type: elementBasically, it use an array of filenames, download these files using $templateRequest and highlight it using Prism.
e.g.
path="snippets"
e.g.
files="['index.html', 'script.js']"
content-before-disabled
Type: attributeDisable for the current instance the global before content inclusion.
content-after-disabled
Type: attributeDisable for the current instance the global after content inclusion.
Themes
Several themes are available, but you can create yours using its scope properties.snippets scope
Stay to false if neither attribute files nor manifest file are available.
Legal
The source for angular-snippets is released under the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.