Template & doT
The template framework renders doT templates, typically for RSS, XML, and other text responses. Many routes declare framework: 'template' as a fallback when no custom index.js exists; custom endpoints can still delegate to the same machinery from index.js.
template.dot
- Primary template file in the endpoint directory.
- Override at runtime with
?template=nameto loadname.dotnext to the default (useful for A/B or partner-specific layouts).
config.js → sources
Each source id describes how to load data before render:
type: 'moxie'— internal request to another Moxie path / handler pattern (see existing RSS endpoints).type: 'static'— inline or bundled static fragments.
Typical fields per source:
request— path / method / paramsmapping— pluck/transform before templatemiddleware— optional preprocessing chain
Study a working partner feed under src/apis/foxnews/rss/ before inventing new shapes.
Specification pairing
- RSS/XML routes usually set
specification: 'xml'(or the site-specific spec used in that route file). - Ensure Content-Type and XML declaration expectations match partner validators (Yahoo, MSN, Google, etc.).
Debugging
?debugga=inputs— data fed into the template layer?debugga=template— rendered output (careful with size in prod debugging)
Performance
- Templates compile at Webpack build time where configured — large templates still benefit from minimal source payloads (avoid fetching unbounded lists).