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

Layouts or smth similar #87

Closed
ognevsky opened this issue Aug 8, 2011 · 11 comments
Closed

Layouts or smth similar #87

ognevsky opened this issue Aug 8, 2011 · 11 comments

Comments

@ognevsky
Copy link
Contributor

ognevsky commented Aug 8, 2011

Hi,

As I know, Rabl don't have any layouts yet. So, the question is: do somebody need this?

@nesquena
Copy link
Owner

nesquena commented Aug 8, 2011

I could see the value for layouts, if there's a certain template all your API's take the form of with a data node or a code node like in instagram's, then I could see this being useful. Personally I haven't had the need for them yet in my own cases.

@ognevsky
Copy link
Contributor Author

ognevsky commented Aug 9, 2011

For instance, I have an app and I need some fields to present in each response: it's for layout, I think. Without them I should add some node or code blocks in every partial.

I'll try to code this and pull request, I hope it'll be helpful for somebody.

@nesquena
Copy link
Owner

nesquena commented Aug 9, 2011

Yeah I can definitely see the value, if you send a pull request with specs and it works well for you im happy to pull it in for the next release.

@ognevsky
Copy link
Contributor Author

ognevsky commented Aug 9, 2011

Fine, I will pull it soon.

@nesquena
Copy link
Owner

nesquena commented Aug 9, 2011

Thanks

@peterjm
Copy link

peterjm commented Sep 2, 2011

I'm interested in this functionality, too. @ognevsky, have you made any progress with an implementation?

I've taken a look at the source for Rabl, but I'm not really sure where to start with implementing layout functionality.

@nesquena
Copy link
Owner

nesquena commented Sep 2, 2011

@peterjm @ognevsly #99 Looks like this guy already has layouts working in RABL as it is? I wonder if layouts just work "out of the box" because of Rails template handlers. Try adding a layout for RABL and see if it works

@peterjm
Copy link

peterjm commented Sep 2, 2011

Thanks, @nesquena. That works for me.

My trouble before was trying to use a .rabl file instead of a .erb file, i.e.

node :data do
  yield
end

Which results in the error "no block given (yield)"

It's a bit of a shame that we need to switch to .erb for the layouts, but hopefully layout files aren't too complicated so it's no major loss. I'm happy enough to move ahead with .erb files.

@nesquena
Copy link
Owner

nesquena commented Sep 2, 2011

Yeah that seems to work for me alright as well, as you said its a shame you need to switch to .erb but in the long run the layouts are fairly simple anyhow. Cheers. Still happy accept a patch for more "complete" support though.

@ognevsky
Copy link
Contributor Author

ognevsky commented Sep 2, 2011

@nesquena I made this like extends works, but then I've tried to add new file in views/layouts/application.json.rabl and it works. The main problem was that I don't know, how to display yield.

So, when my layout contains code(:foo) { :bar }, I see it on page and yield holds string (safe string, don't remember how does it call itself) and I couldn't display this.

So, this code above works (it should work, as I see), you can close this issue I think. No need to make layouts as additional code.

  • sorry for my English ;)

@nesquena
Copy link
Owner

nesquena commented Sep 2, 2011

No problem, thanks for following up. I agree this is a "good enough" solution. Would anyone be kind enough to help document this approach on the wiki for others? https://github.com/nesquena/rabl/wiki/Using-Layouts @ognevsky @peterjm @cblavier .

@nesquena nesquena closed this as completed Sep 2, 2011
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

3 participants