Inline Views

Start building out views in the controller, kinda like building apps in Sinatra

class BlogsController < ApplicationController
  class Index < ApplicationView
    attr_writer :blogs

    def view_template
      h1 { "Blogs" }
      ul {
        @blogs.each do |blog|
          li { a(href: blog_path(blog)) { blog.title } }
        end
      }
    end
  end

  def index
    @blogs = Blog.all
    render component(Index)
  end
end
21 / 39