snippet-helper

An utility library for loading code snippets with Prism highlighting support.

Usage no npm install needed!

<script type="module">
  import snippetHelper from 'https://cdn.skypack.dev/snippet-helper';
</script>

README

Snippet Helper Plugin

The Snippet Helper utility library offers some methods to load code snippets into pages.

Features

  • Loads code snippets
  • Supports Prism highlighting when available.
  • Free to use under MIT

Installation

Via Bower:

bower install snippet-helper

Via npm:

npm install snippet-helper

In a browser:

<script src="snippet-helper.js"></script>

Getting Started

Include jQuery and the plug-in on a page. Create the snippets that should be available under 'snippets' directory and call snippetHelper.loadSnippets

<script type="text/javascript">
    var snippets = [
        {code:"code-ezp-05", ext:"html,js"},
        {code:"code-ezp-01", ext:"html"}
    ];
    $(document).ready(function () {
        loadSnippets(snippets);
    });
</script>

For more information on how to setup and customise, check the examples.

License

Licensed under MIT license.