Socket
Socket
Sign inDemoInstall

create.js

Package Overview
Dependencies
2
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.13 to 0.0.14

65

build/create.js
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.create=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var template = require('./lib/replace');
var utils = require('./lib/utils');

@@ -44,5 +43,3 @@ var of = require('of');

if (of.string(content)) {
frag = create.fragment();
var string = context ? template(content, context) : content;
element.innerHTML = string;
element.innerHTML = content;
} else

@@ -109,49 +106,3 @@

module.exports = create;
},{"./lib/replace":2,"./lib/utils":3,"clas":4,"of":5}],2:[function(require,module,exports){
module.exports = format;
var escapes = {
"<": "&lt;",
">": "&gt;",
"'": '&#39;',
"&": "&amp;",
'"': '&quot;',
"/": '&#x2F;'
};
function escapeString(string) {
return String(string).replace(/[&<>"'\/]/g, function(match) {
return escapes[match];
});
}
function replace(context) {
return function(tag, name) {
if (tag.substring(0, 2) == '{{' && tag.substring(tag.length - 2) == '}}') {
return '{' + name + '}';
}
if (!context.hasOwnProperty(name)) {
return tag;
}
if (typeof context[name] == 'function') {
return escapeString(context[name]());
}
return escapeString(context[name]);
};
}
function format(text) {
var context;
if (arguments[1] && typeof arguments[1] == 'object') {
context = arguments[1];
} else {
context = Array.prototype.slice.call(arguments, 1);
}
return String(text).replace(/\{\{(.+?)\}\}/g, replace(context));
}
},{}],3:[function(require,module,exports){
},{"./lib/utils":2,"clas":3,"of":4}],2:[function(require,module,exports){
var of = require('of');

@@ -197,3 +148,3 @@ var classes = require('clas');

module.exports = utils;
},{"clas":4,"of":5}],4:[function(require,module,exports){
},{"clas":3,"of":4}],3:[function(require,module,exports){
function indexOf(arr, item) {

@@ -249,4 +200,4 @@ return Array.prototype.indexOf.call(arr, item);

module.exports = clas;
},{}],5:[function(require,module,exports){
var of = {}, nodeTypes = [1, 3, 9, 11], types = ['string', 'array', 'object', 'function', 'boolean', 'number', 'undefined', 'arguments'];
},{}],4:[function(require,module,exports){
var of = {}, nodeTypes = [1, 3, 9, 11], types = ['String', 'RegExp', 'Array', 'Object', 'Function', 'Boolean', 'Number', 'Undefined', 'Arguments', 'Date', 'Null'];
of.type = {};

@@ -256,5 +207,5 @@ var toString = function(obj) { return Object.prototype.toString.call(obj); };

types.forEach(function(type) {
of[type] = of.type[type] = function(obj) {
type = type.charAt(0).toUpperCase() + type.slice(1);
return obj !== null && toString(obj) === '[object ' + type + ']';
var name = type.toLowerCase();
of[name] = of.type[name] = function(obj) {
return toString(obj) === '[object ' + type + ']';
};

@@ -261,0 +212,0 @@ });

5

index.js

@@ -1,2 +0,1 @@

var template = require('./lib/replace');
var utils = require('./lib/utils');

@@ -43,5 +42,3 @@ var of = require('of');

if (of.string(content)) {
frag = create.fragment();
var string = context ? template(content, context) : content;
element.innerHTML = string;
element.innerHTML = content;
} else

@@ -48,0 +45,0 @@

{
"name": "create.js",
"version": "0.0.13",
"version": "0.0.14",
"description": "declarative dom creation",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -43,19 +43,2 @@ #create

###basic templating
```javascript
var element = create.div({
classes: ['class', 'class2'],
id: 'identifier',
context: { 'thing': 'THING' },
content: '<div class="thing">{thing}</div>'
});
```
```html
<div class="class class2" id="identifier">
<div class="thing">THING</div>
</div>
```
###create.list

@@ -62,0 +45,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc