Customizing modifiers
This tutorial shows you how you can customize your variable modifiers
Introduction

Changing existing modifiers

Last updated
Was this helpful?
Was this helpful?
{
"categories": {
"object": {
"label": "Object",
"index": 1
},
"list": {
"label": "List",
"index": 2
},
...
},
"modifiers": {
"g_stringify": {
"name": "stringify",
"label": "Stringify",
"category": [
"object",
"list"
],
"description": "Convert an object or list to a JSON string.",
"arguments": [
{
"name": "space",
"type": "number",
"isHash": true
}
],
"returns": {
"type": "string"
},
"helperFn": "function(value, { hash }) {\n\n return JSON.stringify(value, null, hash.space);\n }"
},
"g_length": {
"name": "length",
"label": "Length",
"category": [
"list",
"text"
],
"description": "Find length of text or list.",
"arguments": [],
"returns": {
"type": "number"
},
"helperFn": "function(value) {\n\n return value && value.hasOwnProperty('length') ? value.length : 0;\n }"
},
...
}
}"formatDate": {
"label": "Format Date",
"category": ["date"],
"description": "Transforms the value into given date format",
"arguments": [
{ "name": "Format", "type": "string", "isHash": false }
],
"returns": {
"type": "string"
},
"helperFn": "function(value, format, { helpers }) { return helpers.moment(value).format(format) }"
}"formatDate": {
"label": "Format Date",
"category": ["date"],
"description": "Transforms the value into given date format",
"arguments": [
{ "name": "format", "type": "string", "isHash": true }
],
"returns": {
"type": "string"
},
"helperFn": "function(value, format, { hash: { format }, helpers }) { return helpers.moment(value).format(format) }"
}{
"categories": {
"object": {
"label": "Object",
"index": 1
},
"list": {
"label": "List",
"index": 2
},
...
},
"modifiers": {
"g_stringify": {
"name": "stringify",
"label": "Stringify",
"category": [
"object",
"list"
],
"description": "Convert an object or list to a JSON string.",
"arguments": [
{
"name": "space",
"type": "number",
"isHash": true
}
],
"returns": {
"type": "string"
},
"helperFn": "function(value, { hash }) {\n\n return JSON.stringify(value, null, hash.space);\n }"
},
"g_length": {
"name": "length",
"label": "Length",
"category": [
"list",
"text"
],
"description": "Find length of text or list.",
"arguments": [],
"returns": {
"type": "number"
},
"helperFn": "function(value) {\n\n return value && value.hasOwnProperty('length') ? value.length : 0;\n }"
},
...
// At some place inside the object
"formatDate": {
"label": "Format Date",
"category": ["date"],
"description": "Transforms the value into given date format",
"arguments": [
{ "name": "Format", "type": "string", "isHash": false }
],
"returns": {
"type": "string"
},
"helperFn": "function(value, format, { helpers }) { return helpers.moment(value).format(format) }"
}
}
}