1. 15 4月, 2020 1 次提交
  2. 12 7月, 2019 2 次提交
  3. 13 6月, 2019 1 次提交
  4. 05 4月, 2019 4 次提交
  5. 02 4月, 2019 1 次提交
  6. 28 3月, 2019 1 次提交
    • J
      Introduce Template::File as new render file: · c7820d81
      John Hawthorn 提交于
      The previous behaviour of render file: was essentially the same as
      render template:, except that templates can be specified as an absolute
      path on the filesystem.
      
      This makes sense for historic reasons, but now render file: is almost
      exclusively used to render raw files (not .erb) like public/404.html. In
      addition to complicating the code in template/resolver.rb, I think the
      current behaviour is surprising to developers.
      
      This commit deprecates the existing "lookup a template from anywhere"
      behaviour and replaces it with "render this file exactly as it is on
      disk". Handlers will no longer be used (it will render the same as if
      the :raw handler was used), but formats (.html, .xml, etc) will still be
      detected (and will default to :plain).
      
      The existing render file: behaviour was the path through which Rails
      apps were vulnerable in the recent CVE-2019-5418. Although the
      vulnerability has been patched in a fully backwards-compatible way, I
      think it's a strong hint that we should drop the existing
      previously-vulnerable behaviour if it isn't a benefit to developers.
      c7820d81
  7. 20 3月, 2019 1 次提交
  8. 16 3月, 2019 2 次提交
    • S
      Rename `ActionView::Base#run` to `#_run` · 47fea39e
      Seb Jacobs 提交于
      There was a recent change by @tenderlove to Action view which introduced
      `ActionView::Base#run` [1].
      
      We ran into an issue with our application because one of the core
      concepts in our domain model is a `Run` which is exposed in most of our
      views as a helper method, which now conflicts with this new method.
      
      Although this is a public method it is not really meant to be part of
      the public API.
      
      In order to discourage public use of this method and to reduce the
      chances of this method conflicting with helper methods we can prefix
      this method with an underscore, renaming this method to `_run`.
      
      [1] https://github.com/rails/rails/commit/c740ebdaf5
      47fea39e
    • J
      Remove updated_at from Templates · 80c0ae7d
      John Hawthorn 提交于
      80c0ae7d
  9. 27 2月, 2019 1 次提交
  10. 26 2月, 2019 12 次提交
  11. 23 2月, 2019 1 次提交
    • A
      Add a finalizer to inline templates · 52eafbd7
      Aaron Patterson 提交于
      This commit adds a finalizer just to inline templates.  We can't cache
      compilation of inline templates because it's possible that people could
      have render calls that look like this:
      
      ```ruby
      loop do
        render inline: "#{rand}"
      end
      ```
      
      and we would cache every one of these different inline templates.  That
      would cause a memory leak.  OTOH, we don't need finalizers on regular
      templates because we can cache, control, and detect changes to the
      template source.
      
      Fixes: #35372
      52eafbd7
  12. 18 2月, 2019 1 次提交
  13. 16 2月, 2019 1 次提交
    • A
      Pass the template format to the digestor · 1581cab9
      Aaron Patterson 提交于
      This commit passes the template format to the digestor in order to come
      up with a key.  Before this commit, the digestor would depend on the
      side effect of the template renderer setting the rendered_format on the
      lookup context.  I would like to remove that mutation, so I've changed
      this to pass the template format in to the digestor.
      
      I've introduced a new instance variable that will be alive during a
      template render.  When the template is being rendered, it pushes the
      current template on to a stack, setting `@current_template` to the
      template currently being rendered.  When the cache helper asks the
      digestor for a key, it uses the format of the template currently on the
      stack.
      1581cab9
  14. 07 2月, 2019 2 次提交
  15. 06 2月, 2019 1 次提交
    • A
      Speed up partial rendering by caching "variable" calculation · 24b068be
      Aaron Patterson 提交于
      This commit speeds up rendering partials by caching the variable name
      calculation on the template.  The variable name is based on the "virtual
      path" used for looking up the template.  The same virtual path
      information lives on the template, so we can just ask the cached
      template object for the variable.
      
      This benchmark takes a couple files, so I'll cat them below:
      
      ```
      [aaron@TC ~/g/r/actionview (speed-up-partials)]$ cat render_benchmark.rb
      require "benchmark/ips"
      require "action_view"
      require "action_pack"
      require "action_controller"
      
      class TestController < ActionController::Base
      end
      
      TestController.view_paths = [File.expand_path("test/benchmarks")]
      controller_view = TestController.new.view_context
      
      result = Benchmark.ips do |x|
        x.report("render") do
          controller_view.render("many_partials")
        end
      end
      [aaron@TC ~/g/r/actionview (speed-up-partials)]$ cat test/benchmarks/test/_many_partials.html.erb
      Looping:
      <ul>
      <% 100.times do |i| %>
        <%= render partial: "list_item", locals: { i: i } %>
      <% end %>
      </ul>
      [aaron@TC ~/g/r/actionview (speed-up-partials)]$ cat test/benchmarks/test/_list_item.html.erb
      <li>Number: <%= i %></li>
      ```
      
      Benchmark results (master):
      
      ```
      [aaron@TC ~/g/r/actionview (master)]$ be ruby render_benchmark.rb
      Warming up --------------------------------------
                    render    41.000  i/100ms
      Calculating -------------------------------------
                    render    424.269  (± 3.5%) i/s -      2.132k in   5.031455s
      ```
      
      Benchmark results (this branch):
      
      ```
      [aaron@TC ~/g/r/actionview (speed-up-partials)]$ be ruby render_benchmark.rb
      Warming up --------------------------------------
                    render    50.000  i/100ms
      Calculating -------------------------------------
                    render    521.862  (± 3.8%) i/s -      2.650k in   5.085885s
      ```
      24b068be
  16. 02 2月, 2019 2 次提交
  17. 01 2月, 2019 1 次提交
  18. 19 1月, 2019 1 次提交
    • A
      Ask the view for its method container · 0f081611
      Aaron Patterson 提交于
      Rather than doing is_a? checks, ask the view object for its compiled
      method container.  This gives us the power to replace the method
      container depending on the instance of the view.
      0f081611
  19. 17 1月, 2019 3 次提交
  20. 04 10月, 2018 1 次提交