Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@scaffdog/core

Package Overview
Dependencies
Maintainers
0
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scaffdog/core

@scaffdog/core is a low layer of scaffdog.

  • 4.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@scaffdog/core

@scaffdog/core is a low layer of scaffdog.

Install

Install via npm:

$ npm install @scaffdog/core

Usage

template.md:

# Variables

- key: `{{ input | upper }}`

# `{{ input }}.txt`

```
{{ output.path }}
```

index.ts:

import fs from 'fs';
import path from 'path';
import { createContext, compile } from '@scaffdog/engine';
import { extract } from '@scaffdog/core';

const source = fs.readFileSync('template.md', 'utf8');
const context = createContext({});

const { variables, templates } = extract(source, context);

for (const [key, ast] of variables) {
  context.variables.set(key, compile(ast, context));
}

for (const template of templates) {
  const filename = compile(template.filename, context);

  const data = compile(
    template.content,
    extendContext({
      variables: new Map([
        [
          'output',
          {
            path: filename,
          },
        ],
      ]),
    }),
  );

  fs.writeFileSync(filename, data);
}

// --> Generated "path/to/scaffdog.txt"

Keywords

FAQs

Package last updated on 16 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc