Socket
Book a DemoInstallSign in
Socket

layouts

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

layouts - npm Package Compare versions

Comparing version

to
0.10.4

35

index.js
'use strict';
var lazy = require('lazy-cache')(require);
lazy('falsey', 'isFalsey');
lazy('is-buffer', 'isBuffer');
lazy('delimiter-regex', 'delims');
lazy('get-value', 'get');
var utils = require('./utils');

@@ -41,3 +37,3 @@ /**

function renderLayouts(str, name, layoutStack, opts, fn) {
if (lazy.isBuffer(str)) {
if (utils.isBuffer(str)) {
str = str.toString();

@@ -66,2 +62,3 @@ }

var delims = opts.layoutDelims;
str = toString(str);

@@ -71,3 +68,4 @@ // `data` is passed to `wrapLayout` to resolve layouts

var data = {};
data[opts.tag || 'body'] = str;
var tag = opts.tag || 'body';
data[tag] = str;

@@ -81,4 +79,13 @@ // get info about the current layout

// get the delimiter regex
var re = makeDelimiterRegex(delims);
// ensure that content is a string
var content = toString(layout.contents || layout.content);
if (!re.test(content)) {
throw new Error('cannot find layout tag "' + tag + '" in "' + name + '"');
}
// inject the string into the layout
str = wrapLayout(layout.contents || layout.content, data, delims);
str = wrapLayout(content, data, re);
obj.after = str;

@@ -119,3 +126,3 @@

function assertLayout(value, defaultLayout) {
if (value === false || (value && lazy.isFalsey(value))) {
if (value === false || (value && utils.isFalsey(value))) {
return null;

@@ -134,8 +141,4 @@ } else if (!value || value === true) {

function wrapLayout(content, data, syntax) {
var re = makeDelimiterRegex(syntax);
return toString(content).replace(re, function(_, tagName) {
if (tagName.indexOf('.') !== -1) {
return toString(lazy.get(data, tagName.trim()));
}
function wrapLayout(str, data, re) {
return str.replace(re, function(_, tagName) {
return data[tagName.trim()];

@@ -165,3 +168,3 @@ });

if (Array.isArray(syntax)) {
return (cache[syntax] = lazy.delims(syntax));
return (cache[syntax] = utils.delims(syntax));
}

@@ -168,0 +171,0 @@ }

{
"name": "layouts",
"description": "Wraps templates with layouts. Layouts can use other layouts and be nested to any depth. This can be used 100% standalone to wrap any kind of file with banners, headers or footer content. Use for markdown, HTML, handlebars views, lo-dash templates, etc. Layouts can also be vinyl files.",
"version": "0.10.3",
"version": "0.10.4",
"homepage": "https://github.com/doowb/layouts",

@@ -23,23 +23,20 @@ "author": "Brian Woodward (https://github.com/doowb)",

"scripts": {
"test": "mocha",
"prepublish": "browserify -o browser.js -e index.js -s index --bare"
"test": "mocha"
},
"dependencies": {
"delimiter-regex": "^1.3.1",
"extend-shallow": "^2.0.1",
"falsey": "^0.2.1",
"get-value": "^1.1.5",
"is-buffer": "^1.0.2",
"isobject": "^2.0.0",
"kind-of": "^2.0.0",
"lazy-cache": "^0.2.3",
"noncharacters": "^1.1.0"
"lazy-cache": "^0.2.3"
},
"devDependencies": {
"browserify": "^11.0.1",
"gulp": "^3.9.0",
"gulp-istanbul": "^0.10.0",
"gulp-jshint": "^1.11.2",
"gulp-mocha": "^2.1.3",
"jshint-stylish": "^2.0.1",
"lodash": "^3.10.0",
"mocha": "^2.2.5",
"should": "^7.0.2",
"to-vinyl": "^0.2.0",
"vinyl": "^0.5.0"
"to-vinyl": "^0.2.0"
},

@@ -46,0 +43,0 @@ "keywords": [

@@ -119,3 +119,3 @@ # layouts [![NPM version](https://badge.fury.io/js/layouts.svg)](http://badge.fury.io/js/layouts) [![Build Status](https://travis-ci.org/doowb/layouts.svg)](https://travis-ci.org/doowb/layouts)

### [renderLayouts](index.js#L40)
### [renderLayouts](index.js#L36)

@@ -145,3 +145,3 @@ Wrap one or more layouts around `string`.

* [template-helpers](https://www.npmjs.com/package/template-helpers): Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… [more](https://www.npmjs.com/package/template-helpers) | [homepage](https://github.com/jonschlinkert/template-helpers)
* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Extremely powerful, easy to use, can generate anything from API… [more](https://www.npmjs.com/package/verb) | [homepage](https://github.com/verbose/verb)
* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://www.npmjs.com/package/verb) | [homepage](https://github.com/verbose/verb)

@@ -174,2 +174,2 @@ ## Running tests

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 21, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 08, 2015._
SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.