steveukx / properties

Properties reader for Node.js
MIT License
77 stars 33 forks source link

Parametric properties file #6

Open brunano21 opened 9 years ago

brunano21 commented 9 years ago

I wonder if it's possible to have a parametric property into a file. Let me explain. Suppose into a file I have something like:

[main]
str1 = "stevekx says " + $param1 + "!"

It would be nice, if I could get the str1 value, passing the value of $ param1. Something like:

var a = properties.get('main.str1', 'hello');
console.log(a) --> stevekx says hello!
steveukx commented 9 years ago

Have you considered using the built-in formatting in the util module? https://nodejs.org/api/util.html#util_util_format_format

[main]
str1 = "stevekx says %s!"

var format = require('util').format;
console.log(format(properties.get('main.str1'), 'hello'));
brunano21 commented 9 years ago

Oh I did not consider it. Nice to know. For the moment I was using strformat https://github.com/fhellwig/strformat

hhdem commented 8 years ago

So great to find this solution. Thx guys