resFactory / factory

Resource Factory is a universal approach to originating, refining, and rendering Markdown, HTML, type-safe SQL, or other assets that could comprise static sites or engineering artifacts.
GNU Affero General Public License v3.0
0 stars 3 forks source link

Implement mustache pre-/post-processing and directive #11

Closed shah closed 3 years ago

shah commented 3 years ago

We need to implement mustache.js, M4 or more specifically any really fast logicless template engine for:

For frontmatter:

.resFactory: 
  preProcess:
    frontmatter: yes
    content: no
  postProcess:
    frontmatter: no
    content: yes
key:
  {{tag}}: {{value}}
key2: 
  {{tag2}}: {{value2}}
{{dynamicKey3}}: 
  {{tag2}}: {{value2}}

Frontmatter is allowed in HTML and Markdown files and should be pre-/post-processable to allow dynamic functionality. Markdown is basically just information architecture so allowing it to be dynamic is good.

shah commented 3 years ago

It would be better to use *.md.ts model where the entire Markdown is a Typescript or JS module. This way, frontmatter and others can be dynamic but typesafe too. The nice thing about Deno templates is that they're dynamic, cachable, and remotable (can be sourced from anywhere on the Internet).

Example test.md.ts:

// in *.md.ts all exported symbols are considered "typed" frontmatter
export const title = "Site Workstation Specs Generated";
export const layout: govn.RenderStrategyIdentity = "my/layout/name";

// non-exported symbols can be used in the Markdown but are not treated as frontmatter
const someOtherVar = "value";
const someOtherVar2 = "value";

// the default text is considered the markdown content and may be completely dynamic
export default `
# heading1

${await fetch("completely dynamic URL example")}
${Deno.readTextFileSync("completely dynamic.txt")}
`;