Passed
Push — master ( 61dd3f...482d1b )
by greg
01:51
created

src/cli/cms/templates/handlebars/printJson.js   A

Complexity

Total Complexity 6
Complexity/F 6

Size

Lines of Code 10
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 6
c 1
b 0
f 0
nc 1
mnd 2
bc 3
fnc 1
dl 0
loc 10
rs 10
bpm 3
cpm 6
noi 0
1
2
/**
3
 * Handlebars helper, to print json object
4
 */
5
export default function printJson(obj, escapeString) {
6
  if(typeof obj !== 'undefined' && obj !== null) {
7
    return (typeof escapeString !== null && escapeString !== null && escapeString === 1) ?
8
							escape(JSON.stringify(obj).replace(/'/g, '%27')) :
9
							JSON.stringify(obj).replace(/'/g, '%27')		
10
  }else {
11
    return '{}'
12
  }
13
14
}
15