jsoverson / preprocess

Preprocess HTML, JavaScript, and other files with directives based off custom or ENV configuration
Other
366 stars 80 forks source link

example of @exec #129

Closed chrisathook closed 7 years ago

chrisathook commented 7 years ago

Can anyone provide a better example of @exec? Does the function need to be passed in along with the other variables?

I have a set up like this

{ polyfill: true, collapsedWidth:50, collapsedHeight:75, expandedWidth:100, expandedHeight:125, combine:function (size){

return `${size}px`;

}

that i am passing into preprocess then in my JS file i am trying to do something like this /@exec combine(collapsedHeight)/

but I get

75 px

which is not right.

chrisathook commented 7 years ago

the problem seems to be when the value is written into the ,js file. If i log out the value in the function it is correct but when its written with @exec it adds that space.

combine:function (size){

var start = `${size}px`;
console.log ('!!!!!!!!!!!!!!!!!!!',start);

start = start.replace(/ /g,'')

return start;

}