Section » elements

elements() → array

Retrieve the elements of this section in sequential order. This seamlessly lets you switch from associative readout to sequential readout, allowing sections within, or the whole document, to represent document-like structures (think generic markup) instead of just associative data stores.

enodate: 2018-03-01
title: My blog post

# page

h1: Hello world
p: This is my first post, I'm so happy!
javascriptconst document = eno.parse(input);

const metadata = {
  date: document.field('date', myDateLoaderFunction),
  title: document.field('title')
};

const html = '';

for(let element of document.section('page').elements()) {
  html += `<${element.name}>${element.value()}</${element.name}>`;
}

fs.writeFileSync('index.html', html);

Return value

An array containing the elements of this section.