Closed vjt closed 9 years ago
Having the format in the path is a Rails convention and a one I'm not going to deprecate. This is useful when you are responding with multiple formats, hence having the same file with 2 different formats.
However, we can make the format optional to simplify tests or single formats file.
Thanks, sir.
This still doesn't allow you to use a single template with multiple renderers though, right? That was supposed to be one of the big advantages of Rabl, (being able to render JSON or XML outputs with the same template) which is unfortunately lost here...
@donaldpiret nope, it doesn't - but you can have a look at our fork (compare here) that accomplishes just that. :yellow_heart:
Actually if you are using Rails, you can already name your templates without the format (i.e. index.rabl
) and Rails will find and render them using the correct format from the params.
But I agree, if you're using RablRails.render
you cannot achieve the same behavior. Maybe my options wasn't wisely chosen, I'll check on that.
:+1: :smile:
This commit 5ac7ccd36b0ea300f879940557dedeb6aeffeae9 should fix this issue. As of version 0.4.0, format is not mandatory in your templates names.
As Rabl can render multiple templates, forcing the user to specify the template format in the file name is a limitation.
This commit removes it, while remaining backwards compatible with the legacy format and printing out a deprecation warning.
Eventually, an XML render test was added.
Thanks for considering a merge! :beers:
cc:@lleirborras