↑ Helpers
⚙️ dsv-render
DSV format renderer
This helper renders only static html, just put your DSV code inside fences. It has a subtype no-header
for skiping header formatting. It also can embed csv data using IMP! data embedding API.
This helper uses awesome Papa Parse library for parsing csv.
→ See this page in edit mode.
Example, without subtype
Code
```h:dsv-render
Survived,Sex,Age,Class,value
Perished,Male,Adult,Crew,670
Perished,Male,Adult,Third Class,387
Perished,Male,Adult,Second Class,154
```
Result
Survived | Sex | Age | Class | value |
---|---|---|---|---|
Perished | Male | Adult | Crew | 670 |
Perished | Male | Adult | Third Class | 387 |
Perished | Male | Adult | Second Class | 154 |
Perished | Male | Adult | First Class | 118 |
Perished | Male | Child | Third Class | 35 |
Perished | Female | Adult | Crew | 3 |
Perished | Female | Adult | Third Class | 89 |
Perished | Female | Adult | Second Class | 13 |
Perished | Female | Adult | First Class | 4 |
Perished | Female | Child | Third Class | 17 |
Survived | Male | Adult | Crew | 192 |
Example, subtype 'no-header'
Code
```h:dsv-render/no-header
Survived,Sex,Age,Class,value
Perished,Male,Adult,Crew,670
Perished,Male,Adult,Third Class,387
Perished,Male,Adult,Second Class,154
```
Result
Survived | Sex | Age | Class | value |
Perished | Male | Adult | Crew | 670 |
Perished | Male | Adult | Third Class | 387 |
Perished | Male | Adult | Second Class | 154 |
Perished | Male | Adult | First Class | 118 |
Perished | Male | Child | Third Class | 35 |
Perished | Female | Adult | Crew | 3 |
Perished | Female | Adult | Third Class | 89 |
Perished | Female | Adult | Second Class | 13 |
Perished | Female | Adult | First Class | 4 |
Perished | Female | Child | Third Class | 17 |
Survived | Male | Adult | Crew | 192 |
Data embedding directives
This helper supports "directives" which allow you to embed csv data into the page (see IMP! data embedding) and suppress table rendering. The directives are:
@name: — save data under the given name
This directive may be added like this:
```h:dsv-render
@name:any-name-you-want.csv
your , csv , data
goes , like ,this
If the given name ends with ".json", parsed version of data will be embedded, otherwise data will be embedded as string. The structure of the parsed data depends on subtype: if you use no-header
subtype, it's an array of arrays, otherwise — array of objects with keys, corresponfing to header row content.
@hide — skip table rendering
This directive hides the table from render, if you need this data only for usage in other helpers or your own scripts.
```h:dsv-render
@name:any-name-you-want.csv
@hide
your , csv , data
goes , like ,this
Data embedding example
See here.