@jaredwray/fumanchu 2.1.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/code.js DELETED
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- var fs = require('fs');
4
- var path = require('path');
5
- var utils = require('./utils');
6
- var helpers = module.exports;
7
-
8
- /**
9
- * Embed code from an external file as preformatted text.
10
- *
11
- * ```handlebars
12
- * {{embed 'path/to/file.js'}}
13
- * <!-- optionally specify the language to use -->
14
- * {{embed 'path/to/file.hbs' 'html')}}
15
- * ```
16
- *
17
- * @param {String} `filepath` filepath to the file to embed.
18
- * @param {String} `language` Optionally specify the language to use for syntax highlighting.
19
- * @return {String}
20
- * @api public
21
- */
22
-
23
- helpers.embed = function embed(filepath, ext) {
24
- ext = typeof ext !== 'string' ? path.extname(filepath).slice(1) : ext;
25
- var code = fs.readFileSync(filepath, 'utf8');
26
- if (ext === 'markdown' || ext === 'md') {
27
- ext = 'markdown';
28
- // if the string is markdown, escape backticks
29
- code = code.split('`').join('&#x60');
30
- }
31
- return utils.block(code, ext).trim() + '\n';
32
- };
33
-
34
- /**
35
- * Embed a GitHub Gist using only the id of the Gist
36
- *
37
- * ```handlebars
38
- * {{gist "12345"}}
39
- * ```
40
- * @param {String} `id`
41
- * @return {String}
42
- * @api public
43
- */
44
-
45
- helpers.gist = function(id) {
46
- return utils.tag('script', {src: 'https://gist.github.com/' + id + '.js'});
47
- };
48
-
49
- /**
50
- * Generate the HTML for a jsFiddle link with the given `params`
51
- *
52
- * ```handlebars
53
- * {{jsfiddle id="0dfk10ks" tabs="true"}}
54
- * ```
55
- * @param {Object} `params`
56
- * @return {String}
57
- * @api public
58
- */
59
-
60
- helpers.jsfiddle = function jsFiddle(options) {
61
- var attr = Object.assign({}, options && options.hash);
62
-
63
- if (typeof attr.id === 'undefined') {
64
- throw new Error('jsfiddle helper expects an `id`');
65
- }
66
-
67
- attr.id = 'http://jsfiddle.net/' + attr.id;
68
- attr.width = attr.width || '100%';
69
- attr.height = attr.height || '300';
70
- attr.skin = attr.skin || '/presentation/';
71
- attr.tabs = (attr.tabs || 'result,js,html,css') + attr.skin;
72
- attr.src = attr.id + '/embedded/' + attr.tabs;
73
- attr.allowfullscreen = attr.allowfullscreen || 'allowfullscreen';
74
- attr.frameborder = attr.frameborder || '0';
75
-
76
- delete attr.tabs;
77
- delete attr.skin;
78
- delete attr.id;
79
- return utils.tag('iframe', attr);
80
- };
package/lib/collection.js DELETED
@@ -1,67 +0,0 @@
1
- 'use strict';
2
-
3
- var util = require('handlebars-utils');
4
- var object = require('./object');
5
- var array = require('./array');
6
- var forEach = array.forEach;
7
- var forOwn = object.forOwn;
8
- var helpers = module.exports;
9
-
10
- /**
11
- * Inline, subexpression, or block helper that returns true (or the block)
12
- * if the given collection is empty, or false (or the inverse block, if
13
- * supplied) if the colleciton is not empty.
14
- *
15
- * ```handlebars
16
- * <!-- array: [] -->
17
- * {{#isEmpty array}}AAA{{else}}BBB{{/isEmpty}}
18
- * <!-- results in: 'AAA' -->
19
- *
20
- * <!-- array: [] -->
21
- * {{isEmpty array}}
22
- * <!-- results in: true -->
23
- * ```
24
- * @param {Object} `collection`
25
- * @param {Object} `options`
26
- * @return {String}
27
- * @block
28
- * @api public
29
- */
30
-
31
- helpers.isEmpty = function(collection, options) {
32
- if (!util.isOptions(options)) {
33
- options = collection;
34
- return util.fn(true, this, options);
35
- }
36
-
37
- if (Array.isArray(collection) && !collection.length) {
38
- return util.fn(true, this, options);
39
- }
40
-
41
- var keys = Object.keys(collection);
42
- var isEmpty = typeof collection === 'object' && !keys.length;
43
- return util.value(isEmpty, this, options);
44
- };
45
-
46
- /**
47
- * Block helper that iterates over an array or object. If
48
- * an array is given, `.forEach` is called, or if an object
49
- * is given, `.forOwn` is called, otherwise the inverse block
50
- * is returned.
51
- *
52
- * @param {Object|Array} `collection` The collection to iterate over
53
- * @param {Object} `options`
54
- * @return {String}
55
- * @block
56
- * @api public
57
- */
58
-
59
- helpers.iterate = function(collection, options) {
60
- if (Array.isArray(collection)) {
61
- return forEach.apply(null, arguments);
62
- }
63
- if (util.isObject(collection)) {
64
- return forOwn.apply(null, arguments);
65
- }
66
- return options.inverse(this);
67
- };