Guide
Binding
Handle runtime binding expressions in comark-etiket directives with renderEtiketSvg and etiketTags.
Attributes with a :key prefix that are runtime binding expressions (e.g. :value="user.profileUrl") cannot be resolved at parse time. Those directive nodes are left unchanged in the AST.
A renderer that resolves bindings itself can render those nodes later with renderEtiketSvg.
Render bound directives at request time
render.ts
import { etiketTags, renderEtiketSvg } from 'comark-etiket'
if (etiketTags.has(tag)) {
const svg = await renderEtiketSvg(tag, { value: 'netzo:v1:item:42', 'ec-level': 'M' }, {
defaults: frontmatter.etiket, // per-tag objects override global keys
})
}
Handle return values and errors
renderEtiketSvg returns undefined when:
- etiket is not installed
- the tag is unknown
- the value is empty
It throws when etiket rejects the value.
Use in PDF hosts
PDF hosts (for example Netzo) pass jasy components that call renderEtiketSvg via renderPdf({ components }). comark-pdf does not depend on this package.
etiketTags lists every tag that the package renders.