Installing jade template engine on jsreport

To install Jade / Pug (or any other template engine) with jsreport you con follow these steps:

  1. First off all, create a local folder that will hold the server, i.e.  (~/myTools/jsreport)
  2. Go to that directory. (cd ~/myTools/jsreport)
  3. yarn global add jsreport-cli (you can also use npm install -g jsreport-cli)
  4. Execute the command:  jsreport init (this will create folder structure)
  5. Add jade or ejs or the template engine package to folder with these command: yarn add  jsreport-jade
  6. start the server running jsreport start

That’s  all folks. You should hace jsreport + jade running on port 5488

How to remove a property from a JavaScript Object with ES6 ( ECMAScript 2015 ) – Functional Programming Functional Programming approach

To remove a property from a JS Object, we can take advantage of the destructuring capabilities released in ES6.

Destructuring: It’s a JavaScript expression that allows us to extract data as variables or constants directly from arrays, objects, maps and sets

const removeXProperty = ({x, ...rest}) => rest

Before we have to use the delete operator

const removeXProperty = function(obj) {
 delete obj.x
 return x
}

This way seems better for javascript functional programming.

const employees = [
  {name: 'Pedro', age: 35, address: AddrObj },
  {name: 'Charlie', age: 55, address: AddrObj },
  ... 
]

const removeAddress = ({address, ...rest}) => rest

// If we wan't to remove address from the array we would do


console.log( employees.map(removeAddress) )

    CONSOLE LOG
--------------------------
[
   {name: 'Pedro',age: 35},
   {name: 'Charlie', age: 55}
]

Another very useful thing we can do with destructuring is to modify the value of a property using very little code. For example if we wan’t to uppercase only the name we could do:

const employees = [
  {name: 'Pedro', alias: 'toto', age: 35 },
  {name: 'Charlie', alias: 'titan', age: 55 },
  ... 
]

const nameToUpCase = ({name, ...rest}) => ({...rest, name: name.toUpperCase()})

// If we wan't to upperCase the name we would do

console.log( employees.map(nameToUpCase) )

 CONSOLE LOG
--------------------------
[
 {name: 'PEDRO', alias: 'toto', age: 35},
 {name: 'CHARLIE', alias: 'titan', age: 55}
]

Hope it works for you,

Cheers,