Open RobLoach opened 8 years ago
I agree that the API seems useful and interesting. I feel like it might be confusing for the JSON
transformer. Perhaps the methods should be toObject
and fromObject
or perhaps even parse
and stringify
such that the JSON
object would be automagically compatible.
One thought, can we figure out a good way to handle blocks of metadata at the top of files e.g.
title="about metadata"
author= "Forbes Lindesay"
---
h1 Metadata
p This article is in jade, but has some TOML metadata at the beginning
Ideally it would be good to be able to do something like:
file |> read metadata |> toml.parse |> json.stringify
file |> remove metadata |> jade.render
Question 1: Are there lots of different ways of representing metadata as part of a file with other content? Could we supply a unified API on top of them?
Question 2: Do these two new APIs (meta data reading and removing + to/from object) belong as part of jstransformers? I'm beginning to think maybe they do, because we could envision providing parse
methods for things like css
, jade
etc. alongside also providing a render
method, but my gut reaction was initially no.
For each transformer,
render()
takes an input string, and outputs a string. There are cases, however, where we want to deal with straight objects, like TOML/INI/YAML/etc.Proposal
We should add
toJSON
/fromJSON
method to each Transformer, similar torender()
, but outputs an object rather rather than a string.Example
This converts an INI string to YAML:
Given this, we would be able to easily convert any format to and from any other format without having to parse through JSON.stringify all the time.