Git Product home page Git Product logo

Comments (11)

stoeffel avatar stoeffel commented on June 8, 2024

both to accept only arrays (or plural array, singular only string?)

I would accept only strings for singular and plural only arrays.

from jstransformer.

RobLoach avatar RobLoach commented on June 8, 2024

I'd actually opt to removing outputFormat entirely.

from jstransformer.

tunnckoCore avatar tunnckoCore commented on June 8, 2024

I would accept only strings for singular and plural only arrays.

yea, exactly. I thought for something like this

var outputFormat = this._tr.outputFormat || this._tr.outputFormats;
var inputFormat = this._tr.inputFormat || this._tr.inputFormats || this.name;

outputFormat = Array.isArray(outputFormat) ? outputFormat : [outputFormat];
inputFormat = Array.isArray(inputFormat) ? inputFormat : [inputFormat];

this.outputFormat = this.outputFormats = outputFormat;
this.inputFormat = this.inputFormats = inputFormat;

from jstransformer.

tunnckoCore avatar tunnckoCore commented on June 8, 2024

I'd actually opt to removing outputFormat entirely.

why?

from jstransformer.

RobLoach avatar RobLoach commented on June 8, 2024

Remove outputFormat because it makes assumptions on the context of the application. As you demonstrated, the output can be changed based on the options passed to the Tranformer.

I've used Mustache to output CSS before, I've used ECO to output JavaScript. There is no way for us to determine what's expected for the output, so we should make no assumption in the matter.

from jstransformer.

stoeffel avatar stoeffel commented on June 8, 2024

There is no way for us to determine what's expected for the output, so we should make no assumption in the matter

true

from jstransformer.

tunnckoCore avatar tunnckoCore commented on June 8, 2024

hmm. good point.

from jstransformer.

tunnckoCore avatar tunnckoCore commented on June 8, 2024

@jstransformers/owners one more use case
https://github.com/jstransformers/jstransformer-gray-matter - what should be inputFormats/outputFormat? text? it accept and output markdown, html, css, html and etc, common used for markdown, hbs, mustache and etc.

from jstransformer.

tunnckoCore avatar tunnckoCore commented on June 8, 2024

and actually, all template engines or even just mustache-like engines can output just simple text not html, its based on the context of the application

from jstransformer.

tunnckoCore avatar tunnckoCore commented on June 8, 2024

oh, yea, outputFormat is json, but what to be the inputFormats?

from jstransformer.

ForbesLindesay avatar ForbesLindesay commented on June 8, 2024

The purpose of outputFormat is to define a default output format for a given transformer. I.e. If asked to transform a file with a given transformer and told nothing else, what file extension should I use for the output by default.

The purpose of inputFormats is to list the input file extensions that correspond to a given transformer. I.e. If I'm given a collection of files and a collection of transformers, which transformer should I use for which file.

These use cases should hopefully make it clear that there's not much use in having an array for outputFormat, but it does make sense to have an array of inputFormats

from jstransformer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.