Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

express-view-helpers

Package Overview
Dependencies
0
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0 to 0.0.1

tests/cssTag.js

77

lib/helpers.js
var helpers = {
linkTo: function(text, url) {
return "<a href='" + url + "'>" + text + "</a>"
linkTo: function(text, url, options) {
options = options || {}
options.href = url
return "<a " + hashToAttributes(options) + ">" + text + "</a>"
},
cssTag: function(path) {
return "<link rel='stylesheet' href='" + path + "' type='text/css' charset='utf-8'>"
cssTag: function(path, options) {
options = options || {}
options.rel = 'stylesheet'
options.href = path
options.type = 'text/css'
options.charset = 'utf-8'
return "<link " + hashToAttributes(options) + ">"
},
jsTag: function(path) {
return "<script type='text/javascript' src='" + path + "' charset='utf-8'></script>"
jsTag: function(path, options) {
options = options || {}
options.type = 'text/javascript'
options.src = path
options.charset = 'utf-8'
return "<script " + hashToAttributes(options) + "></script>"
},
label: function(name, text) {
return "<label for='" + name + "'>" + text + "</label>"
label: function(name, text, options) {
options = options || {}
options.for = name
return "<label " + hashToAttributes(options) + ">" + text + "</label>"
},
submitTag: function(text) {
return "<input type='submit' value='" + text + "'>"
submitTag: function(text, options) {
options = options || {}
options.type = 'submit'
options.value = text
return "<input " + hashToAttributes(options) + ">"
},
imageTag: function(src, alt) {
return "<img src='" + src + "' alt='" + alt + "' />"
imageTag: function(src, options) {
options = options || {}
options.src = src
return "<img " + hashToAttributes(options) + " />"
},

@@ -23,18 +47,25 @@ require: require

var injectInputHelper = function(helperName, type) {
helpers[helperName] = function(name, value, options) {
options = options || {}
var result = "<input type='" + type + "' name='" + name + "'"
if(options.id)
result += " id='" + options.id + "'"
return result + ">"
var hashToAttributes = function(hash) {
var result = []
for(var key in hash) {
var value = hash[key]
if((value != null) && (typeof value != 'undefined')) {
result.push(key + "='" + value + "'")
}
}
return result.join(" ")
}
var types = ['text', 'password']
types.forEach(function(type) { injectInputHelper(type + 'Field', type) })
types.forEach(function(type) {
helpers[type + 'Field'] = function(name, value, options) {
options = options || {}
options.type = type
options.name = name
options.value = value
return "<input " + hashToAttributes(options) + ">"
}
})
module.exports = helpers
{
"name": "express-view-helpers",
"description": "Some view helpers for expressjs.",
"version": "0.0.0",
"version": "0.0.1",
"repository": {

@@ -15,3 +15,6 @@ "type": "git",

"node": "*"
}
},
"files": [
""
]
}
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