Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export bh instance as template result #1

Open
just-boris opened this issue Dec 22, 2015 · 4 comments
Open

Export bh instance as template result #1

just-boris opened this issue Dec 22, 2015 · 4 comments

Comments

@just-boris
Copy link
Contributor

Consider two options.

var bh = require('bh!./block.bh.js');
bh.apply({block: 'block'});
var apply = require('bh!./block.bh.js');
apply({block: 'block'});

the second option is nice because it exposes function as well it does handlebars and jade loaders

@mightyaleksey
Copy link
Member

I suspect that the second variant is slightly better, cause it's easier to understand and to use. Also it restricts undocumented ways of usage.

But still, we have to provide the full API if the user will require runtime module.

@mightyaleksey
Copy link
Member

btw, I just thought, we can wrap runtime.js module in the custom API also. Since we are making a wrapper for the template engine wrapper, we need only two possibilities: to add new template and to transform bemjson into html.

What do you think, if we implement runtime.js module with smthing like that:

var bh = new require('bh').BH;

module.exports = function (bemjson) {
  return bh.apply(bemjson);
}

module.exports.add = function (name, template) {
  bh.match(name, template);
};

@just-boris
Copy link
Contributor Author

The last example is not ok because method add doesn't match with bh's method match. It is confusing.

Also, I don't think that we have a custom API. We are just instantiating BH. ENB does exactly the same thing here: https://github.com/enb-bem/enb-bh/blob/master/techs/bh-commonjs.js#L129

@mightyaleksey
Copy link
Member

Well, I wanted to make it slightly better. Also I wanted to have the same API from the template and runtime.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants