Back to results
plmrry/rollup-plugin-archieml(opens in a new tab)
Language: JavaScript
Parse ArchieML files with Rollup
- stars
- 4
- watchers
- 0
- forks
- 0
- open issues
- 0
- Last updated
- 01/25/2023
Language: JavaScript
Parse ArchieML files with Rollup
A Rollup plugin which converts ArchieML files into JavaScript modules.
npm install rollup-plugin-archieml --save-devCreate a rollup.config.js configuration file and import the plugin:
import archieml from "rollup-plugin-archieml"; export default { input: "src/index.js", output: { dir: "output", format: "cjs", }, plugins: [archieml()], };
Then call rollup either via the CLI or the API.
Given an ArchieML file called events.aml:
[+events]
header: My Birthday
date: August 20th, 1990
Here's a nice photo
{.image}
src: http://example.com/photo.png
alt: Family Photo
[.members]
* Dad
* Mom
* Me
[]
{}
[]
Using this plugin, we can import (or require) the ArchieML file directly:
import events from "./events.aml"; console.dir(events, { depth: null }); // { // events: [ // { type: 'header', value: 'My Birthday' }, // { type: 'date', value: 'August 20th, 1990' }, // { type: 'text', value: "Here's a nice photo" }, // { // type: 'image', // value: { // src: 'http://example.com/photo.png', // alt: 'Family Photo', // members: [ 'Dad', 'Mom', 'Me' ] // } // } // ] // }