jstransformers / jstransformer Goto Github PK
View Code? Open in Web Editor NEWNormalize the API of any JSTransformer.
Home Page: http://npm.im/jstransformer
License: MIT License
Normalize the API of any JSTransformer.
Home Page: http://npm.im/jstransformer
License: MIT License
@tunnckoCore brought this up in https://github.com/jstransformers/meta/issues/2 .
I believe a large chunk of these tools will be handled by https://github.com/jstransformers/nuke or whatever we end up adding in there.
https://www.npmjs.com/package/hamljs
We've got haml
, but not hamljs
.
In transformers, 'xml'
is used, even for HTML output.
In the first few packages ported by @ForbesLindesay, they are marked as 'html'
.
In my first few packages, I used 'html'
as well, but then I saw that transformers was using 'xml'
, so I switched to 'xml'
.
What exactly should I use?
What about hybrids like XHTML/XML: https://github.com/jstransformers/jstransformer-cdata?
When the transformer doesn't have .compile()
, but does have .render()
, jstransformer.compile()
could create it.....
Transformer.prototype.compile = function (str, options) {
if (!this.can('compile')) {
// Fall back to tr.render(), if it's available.
if (this.can('render')) {
var _this = this;
return tr.normalizeFn(function (locals) {
return _this._tr.render(str, options, locals);
});
}
We have outputFormat
to define what the outcome of the tranformer is. Should we also define an inputFormat
to say what the input for the transformer usually is?
SCSS could become scss
, defaulting from the exports.name
.
While Remarkable, Marked, Markdown, etc would define:
exports.inputFormats = ['md', 'markdown'];
@stoeffel asked in https://github.com/jstransformers/meta/issues/3
What do you think about creating a generator-jstransformer for yeoman, to simplify the process of creating new jstransformers?
@hemanth replied
Well, at the rate at which the modules are being churned, we will exhaust our todo list soon, but anyway it would be any harm to have a generator ๐
BTW, if you haven't noticed yet, there is a bolierplate.
For example currently compileFileAsync does this:
Say I supply a synchronous compileFile, compileFileAsync is basically forced to use synchronous file IO, which might be suboptimal.
I propose a compileFileCommon
function that handles the stuff common to both functions when compile
is synchronous, and jstransformer automatically adding the file I/O operations.
Same goes for compileClient
and compileClientAsync
.
The centered logo distracts the user from the documentation, which is more important. Also looks weird on npm: https://www.npmjs.com/package/jstransformer
Let's do what Promises does for their logo:
I.e. what each function takes in and can return.
We should discuss the licensing/copyright issue. At the moment everything is consistently MIT. That's great and I see no reason to change that. It does, however seem a bit odd to have the copyright assigned to individual people for individual repos. Especially as with the project ultimately maturing, many of the modules may end up being primarily maintained by someone who didn't initially create them.
Could we assign copyright to "jstransformers" as an organisation? Are there any legal issues? Does anyone have any other objections?
wazza :)
xml2js
have only async, soo.. i should implement only .renderAsync
, right? But when implement it like
exports.renderAsync = function _renderAsync(str, opts, locals, callback) {
xml2js.parseString(str, opts, callback);
};
then when try it
var transform = require('jstransformer')(require('../index'));
transform.renderAsync(fixture, {}, {}, function(err, res) {
console.log(err, res)
});
or like
var transform = require('jstransformer')(require('../index'));
var promise = transform.renderAsync(fixture);
// throws error to .catch
it throws [Error: Invalid result object from transform.]
in both cases
I dont know why, but for some reason it fails to populate template with given locals in some template engines like handlebars and I guess other was toffee. check this and this, its not logical to fail, because other render* methods works correctly.
For that reason Im so strong with my position to use jstransformer
for testing it helps to find bugs like this, have more useful use cases which in other hand in one point is useful as examples.
Okey guys, some points. Inspiration jstransformers/jstransformer-liquor#1 and tests like that
Please, lets come to that to use jstransformer
for all the modules. It will be just in devDeps, so I dont see the problem.
Current testing flow is awful for me. Tests should be descriptive, should be as an examples, should test some more real use-cases (I mean, more than just hello {{name}}
) or template engine specifics, also should have descriptive descriptions.
Tests should be like these.
What is that "Mote.js" description (mentioning jstransformer-mote test)? - Nothing.
You even set transform.name
as test description in our generator.
Using testit
for just one simple line saying "mote.js" or "liquor" to the stdout, whaa?!
Tests like this dont have meaning for me. They told me nothing, what remains to users?
I also dont like very much assert.equal
, so assertit
.equal is assert's strictEqual
assertit is enhancement, thin layer on top of testit
and assert
- read it's tests to see the actual usage.
@ForbesLindesay @RobLoach i think it should be text
not exactly html
as now in mustache
transformer
I see lots of use of strings, but haven't seen much implementation surrounding Streams. Any thoughts?
Rather than returning the {dependencies, body}
for .render()
and .renderFile()
, have it return a Promise?
Or switch over to Generators and yield
for everything?
Now that there are a good amount of Transformers available from #1, it is time to think about what the next steps are for JS Transformers' success. So, what is missing?
.compile
function for templates?npm
?I put together a Metalsmith plugin to use JSTransformer, and thought it would be a good idea to have a list of potential ideas for other integration points with external systems to help encourage collaboration. Feel free to edit this list and add any other ideas.
metalsmith-jstransformer
jstransformers
org? I could move metalsmith in.This project aims to replace transformers with a large collection of separate libraries, each of which able to be separately maintained, tested and updated. Each library will implement some subset of the API in this module, and may optionally return a string body rather than the {body: String, dependencies: Array.<String>}
format (lots of file formats don't actually have dependencies so it wouldn't really make sense). This module can then be used to fully normalise that interface, including implementing the methods that are otherwise not implemented.
Here is a list of all the modules that need implementing
Once all of these have been implemented, we can switch jade to look for these rather than transformers. I'll need as many collaborators as possible for this, so if you're willing to contribute a transformer, let me know and I'll add you to the organisation. P.S. note that we add jstransformer
to the keywords in package.json for all transformers, so they can be found at https://www.npmjs.com/browse/keyword/jstransformer
Also the names of properties.. We need more consistency.
outputFormats
alias to outputFormat
inputFormats
alias to inputFormat
exports.name = 'absurd';
exports.inputFormats = ['absurd', 'absurdjs', 'js', 'json', 'yaml', 'css'];
exports.outputFormats = ['css', 'html'];
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.