This plugin provides DocPad with CSV data mapping. CSV are numbers that represent the cost of an item or a mapping from one value to another.
npm install --save docpad-plugin-csv
To use, first create the
src/csv directory, and place any set of config files you want to use in there.
Then in our templates we will be exposed with the
@csv(config_file,data_point) function. The
data_point argument is NOT optional, and is used to send custom data to the csv's
The following options are available: csvPath - [csv] directory name under `src' where the csv files are loaded from currency - [''] What currency symbol you want to use if you are outputting prices decimal -  How many decimal places are displayed decimalPoint - ['.'] What symbol is used to represent the decimal point thausandSep - [','] What symbol is used to represent the thousand seperator in numbers. Use '' if you dont want any. defExtension - ['csv'] This is added to each of the data filenames used into the commands. Just makes it shorter to type. zeroIs - ['TBD'] When a price is created and the value is 0 then this is used to represent the 0.
Create a file called
test.csv in the
Add the following two lines:
XYZ, Hello there
This basically is a mapping from
1559 and from
Inside a test document we can use this command to replace
ABC entries with the value from the csv file.
<%- @csv('test', 'ABC') %> will produce
<%- @csv('test', 'DEF') %> will produce
<%- @csv('test', 'XYZ') %> will produce
If you are working with numbers then you can also do this:
<%- @csvPrice('test', 'ABC') %> will produce
<%- @csvPrice('test', 'DEF') %> will produce
or if you want numbers but no decimals:
<%- @csvPriceNoDec('test', 'ABC') %> will produce
<%- @csvPriceNoDec('test', 'DEF') %> will produce
You can discover the history inside the