Bug: Options are not passed to the compiler and html parser #1801

Closed
fernandogmar opened this Issue May 19, 2016 · 4 comments

Projects

None yet

4 participants

@fernandogmar
fernandogmar commented May 19, 2016 edited
  1. Describe your issue:

I was doing something different with RIOTJS trying to compile a tag with a custom html parser on the browser:

            riot.parsers.html.swig = function(html, opts, url) {
                return swig.render(html, {
                    locals: opts
                });
            }
            riot.compile("scripts/swig.tag", function(){
                riot.mount('swig');
            }, {
                template: 'swig',
                parserOptions: {
                    template: {
                        whatever: 'here'
                    }
                }
            });

And I realized that in some point of the code the opts are not passed, I think I have been lucky just debugging a bit and I found this:

      // `riot.compile(url [, callback][, options])`
      GET(arg, function (str, opts, url) {
        var js = compile(str, opts, url)
        globalEval(js, url)
        if (fn) fn(js, str, opts)
      })

in the callback of GET opts are always undefined... I think the third argument is missing, so this should be something as:

      // `riot.compile(url [, callback][, options])`
      GET(arg, function (str, opts, url) {
        var js = compile(str, opts, url)
        globalEval(js, url)
        if (fn) fn(js, str, opts)
      }, opts)

notice last argument opts added in this case

  1. Which version of Riot does it affect?
    I was using version 2.4.0
  2. How would you tag this issue?
    • Question
    • [X ] Bug
    • Discussion
    • Feature request
    • Tip
    • Enhancement
    • Performance
@GianlucaGuarini
Member

I remember we have already discussed about this topic.. @aMarCruz can you have a look at this task in the next major release of riot (riot-compiler) please?

@aMarCruz
Member
@aMarCruz aMarCruz self-assigned this May 19, 2016
@cdiglesias

This bug remains

@aMarCruz
Member

@fernandogmar thank you, your patch is in the dev branch now and will be included in the next version.

@aMarCruz aMarCruz closed this Jul 19, 2016
@aMarCruz aMarCruz added bug and removed enhancement labels Jul 19, 2016
@aMarCruz aMarCruz added a commit that referenced this issue Jul 20, 2016
@aMarCruz aMarCruz Closes #1801 - Options are not passed to the compiler and html parser…
… (Cannot test external URLs)
94eadb7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment