1

How can I generate a path or URL in a view in Roda?

Will I need to use a plugin? If not, how else? Or will I have to hard-code urls/paths?

In Rails I'd do this way:

<%= home_about_path %>
Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59
Bingi
  • 59
  • 6

1 Answers1

3

To just generate urls based on set semantics, you want the path plugin.

Usage looks something like this:

App < Roda
  plugin :path

  path :post do |post|
    "/blog/#{post.id}"
  end
end

And then, in your templates similarly to how you would use something_path in Rails:

<a href="<%= post_path(@post) %>" class="btn"><%= @post.title %></a>
Maciej Szlosarczyk
  • 789
  • 2
  • 7
  • 21