New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

xsalt

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xsalt - npm Package Compare versions

Comparing version 0.0.9 to 0.1.0

2

bower.json
{
"name": "xsalt",
"main": "xsalt.js",
"version": "0.0.9",
"version": "0.1.0",
"homepage": "https://github.com/chocolatetoothpaste/xsalt",

@@ -6,0 +6,0 @@ "authors": [

{
"name": "xsalt",
"version": "0.0.9",
"version": "0.1.0",
"description": "A different kind of template engine",

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

@@ -101,3 +101,16 @@ # xsalt

// Default values: 'default' attribute was added (v0.1.0)
// the function for mapping nested objects was updated and will now return
// and empty object if not matching key is found. this may cause unexpected
// results, please test/verify your template output
// output: <input type="text" value="stewie">
// no data passed to compile to force defalut value to be used
var out = xsalt('<xs:input type="text" val="username" default="stewie">').compile();
// defalut innerHTML
// output: <button type="button">Click me!</button>
var button = xsalt('<xs:button type="button" html="fakester.nested.value">Click me!</xs:button>').compile();
### API
Coming soon. For now see the examples.
Coming eventually. For now see the examples.

@@ -5,3 +5,3 @@ if( typeof module !== 'undefined' && module.exports ) {

/*//
var data = {

@@ -26,2 +26,10 @@ users: [

console.log("Result: ", test);
console.log("Result: ", test);
/*/
// var button = xsalt('<xs:button val="text" html="html">Click here</button>').compile({ , html: "xsaltHTML" });
var button = xsalt('<xs:button val="text.some.nested.property" html="html">Click here</button>').compile({text: "xsaltValue"});
console.log(button);
//*/

@@ -31,5 +31,11 @@ (function(document) {

xsalt.prototype.map = function( keys, data ) {
return keys.reduce(function (data, key) {
return data[key];
}, data);
// make sure data and data[key] exist
if( typeof data !== "undefined" && typeof data[key] !== "undefined" )
return data[key];
// return empty object...? maybe a bad practice, needs exploration
// it *might* be better to throw an error here
}, data) || {};
};

@@ -69,3 +75,6 @@

'html': function( node, key, data ) {
node.innerHTML = data[key];
if( typeof data[key] !== "undefined" ) {
node.innerHTML = data[key];
}
node.removeAttribute('html');

@@ -75,3 +84,15 @@ },

'val': function( node, key, data ) {
node.setAttribute('value', data[key]);
var val = '';
if( typeof data[key] !== "undefined" ) {
val = data[key];
}
else if( node.hasAttribute('default') ) {
val = node.getAttribute('default');
node.removeAttribute('default');
}
node.setAttribute('value', val);
node.removeAttribute('val');

@@ -78,0 +99,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc