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

require.JS paths are hardcoded in beautify-html.js #359

Closed
attodorov opened this issue Nov 12, 2013 · 3 comments
Closed

require.JS paths are hardcoded in beautify-html.js #359

attodorov opened this issue Nov 12, 2013 · 3 comments

Comments

@attodorov
Copy link

I am referring to this line of code:

define(["./beautify.js", "./beautify-css.js"], function(js_beautify, css_beautify) {

If i define require config in my app (index.html or whatever), in the following format:

require.config({
        baseUrl: 'js',
        paths: {
            'beautify': '../bower_components/js-beautify/js/lib/beautify',
            'css-beautify': '../bower_components/js-beautify/js/lib/beautify-css',
            'html-beautify': '../bower_components/js-beautify/js/lib/beautify-html'
              }
});

I cannot use it like this:

var jsbeautify = require("beautify");
var htmlbeautify = require("html-beautify").html_beautify;

Wouldn't it be better to do something like this:

define(["beautify", "css-beautify"], function(js_beautify, css_beautify) {

and then allow developers to point to any location via require "paths". In this way my beautify.js and beautify-css.js don't have to be in my base path, but can be anywhere. this makes it particularly useful with bower.

Thanks
Angel

@bitwiseman
Copy link
Member

Thanks for this report.

(I updated your description to make the code sections more readable - you might take a minute to review and use that markdown in the future.)

I know almost nothing about bower or require.js. If you have a suggested improvement, please implement and submit a pull request. If you can include tests for your suggested improvement, that would be even better. 😄

@Aaike
Copy link

Aaike commented Jan 15, 2014

This issue still doesnt seem to be fixed. i have forked the repo and submitted a pull request #387.

using relative paths is the best way to do it.
but this has to happen inside the define request for it to work using requirejs in a browser.

usage is described below.

define the paths :

 paths: {
     'beautify': '../bower_components/js-beautify/js/lib/beautify',
     'css-beautify': '../bower_components/js-beautify/js/lib/beautify-css',
     'html-beautify': '../bower_components/js-beautify/js/lib/beautify-html'
 }

require the module:

html_beautify = require("html-beautify").html_beautify;

beautify some code :

var result = html_beautify(data);

@bitwiseman
Copy link
Member

@attodorov - I've submitted 9c65674 which uses the relative paths solution proposed by @Aaike. I'm going to close this, and it will be included in the next release. Please have a look and say if this is sufficient. If not I will reopen.

@bitwiseman bitwiseman added this to the v1.5.0 milestone Apr 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants