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

Locals lost after first cycle #1459

Closed
oniram88 opened this issue Aug 10, 2018 · 0 comments
Closed

Locals lost after first cycle #1459

oniram88 opened this issue Aug 10, 2018 · 0 comments

Comments

@oniram88
Copy link
Contributor

Steps to reproduce

You need a set of elements in a page and render with locals

<%= render_elements from_page: "menu_header", locals:{desktop:true} %>

Expected behavior

the locals will be pass to every rendere_element in this function:

def render_element_view_partials(elements, options = {})
      buff = []
      elements.each_with_index do |element, i|
        buff << render_element(element, :view, options, i + 1)
      end
      buff.join(options[:separator]).html_safe
end

Actual behavior

alfter the first render_element the options hash is cleared from the locals key:

locals: options.delete(:locals) || {}

System configuration

  • Alchemy Version: 4.1.0.rc1
  • Rails Version: 5.2.0
  • Contents of your Gemfile.lock
GIT
  remote: https://github.com/AlchemyCMS/alchemy-devise.git
  revision: 4543f7c97ea1c7e4d88d7a2fab63731da45554b4
  specs:
    alchemy-devise (4.1.0.beta)
      alchemy_cms (>= 4.0.0.beta, < 4.99)
      devise (>= 4.0, < 4.99)

GEM
  remote: https://rubygems.org/
  remote: https://rails-assets.org/
  specs:
    actioncable (5.2.0)
      actionpack (= 5.2.0)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailer (5.2.0)
      actionpack (= 5.2.0)
      actionview (= 5.2.0)
      activejob (= 5.2.0)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.2.0)
      actionview (= 5.2.0)
      activesupport (= 5.2.0)
      rack (~> 2.0)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.2.0)
      activesupport (= 5.2.0)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    active_model_serializers (0.9.7)
      activemodel (>= 3.2)
      concurrent-ruby (~> 1.0)
    activejob (5.2.0)
      activesupport (= 5.2.0)
      globalid (>= 0.3.6)
    activemodel (5.2.0)
      activesupport (= 5.2.0)
    activerecord (5.2.0)
      activemodel (= 5.2.0)
      activesupport (= 5.2.0)
      arel (>= 9.0)
    activestorage (5.2.0)
      actionpack (= 5.2.0)
      activerecord (= 5.2.0)
      marcel (~> 0.3.1)
    activesupport (5.2.0)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    acts_as_list (0.9.14)
      activerecord (>= 3.0)
    addressable (2.5.2)
      public_suffix (>= 2.0.2, < 4.0)
    airbrake (5.8.1)
      airbrake-ruby (~> 1.8)
    airbrake-ruby (1.8.0)
    airbrussh (1.3.0)
      sshkit (>= 1.6.1, != 1.7.0)
    alchemy_cms (4.1.0.rc1)
      active_model_serializers (~> 0.9.0)
      acts_as_list (~> 0.3)
      awesome_nested_set (~> 3.1)
      cancancan (~> 2.1)
      coffee-rails (~> 4.0)
      dragonfly (~> 1.0, >= 1.0.7)
      dragonfly_svg (~> 0.0.4)
      gutentag (~> 2.2, >= 2.2.1)
      handlebars_assets (~> 0.23)
      jquery-rails (~> 4.0, >= 4.0.4)
      jquery-ui-rails (~> 6.0)
      kaminari (~> 1.1)
      non-stupid-digest-assets (~> 1.0.8)
      originator (~> 3.1)
      rails (~> 5.0, < 6.0)
      ransack (~> 1.4)
      request_store (~> 1.2)
      responders (~> 2.0)
      select2-rails (>= 3.5.9.1, < 4.0)
      simple_form (~> 4.0)
      turbolinks (>= 2.5)
    archive-zip (0.11.0)
      io-like (~> 0.3.0)
    arel (9.0.0)
    autoprefixer-rails (8.6.2)
      execjs
    awesome_nested_set (3.1.4)
      activerecord (>= 4.0.0, < 5.3)
    bcrypt (3.1.12)
    bindex (0.5.0)
    bootsnap (1.3.0)
      msgpack (~> 1.0)
    bootstrap (4.0.0)
      autoprefixer-rails (>= 6.0.3)
      popper_js (>= 1.12.9, < 2)
      sass (>= 3.5.2)
    bourbon (5.0.1)
      sass (~> 3.4)
      thor (~> 0.19)
    builder (3.2.3)
    byebug (10.0.2)
    cancancan (2.2.0)
    capistrano (3.11.0)
      airbrussh (>= 1.0.0)
      i18n
      rake (>= 10.0.0)
      sshkit (>= 1.9.0)
    capistrano-db-tasks (0.6)
      capistrano (>= 3.0.0)
    capybara (3.2.0)
      addressable
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.8)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      xpath (~> 3.1)
    childprocess (0.9.0)
      ffi (~> 1.0, >= 1.0.11)
    chromedriver-helper (1.2.0)
      archive-zip (~> 0.10)
      nokogiri (~> 1.8)
    coffee-rails (4.2.2)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.12.2)
    concurrent-ruby (1.0.5)
    cookie_law (0.1.2)
    crass (1.0.4)
    devise (4.4.3)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0, < 6.0)
      responders
      warden (~> 1.2.3)
    dragonfly (1.1.5)
      addressable (~> 2.3)
      multi_json (~> 1.0)
      rack (>= 1.3)
    dragonfly_svg (0.0.4)
      dragonfly (~> 1.0)
      nokogiri
    erubi (1.7.1)
    execjs (2.7.0)
    ffi (1.9.25)
    font-awesome-rails (4.7.0.4)
      railties (>= 3.2, < 6.0)
    friendly_id (5.2.4)
      activerecord (>= 4.0.0)
    globalid (0.4.1)
      activesupport (>= 4.2.0)
    gutentag (2.4.0)
      activerecord (>= 3.2.0)
    handlebars_assets (0.23.2)
      execjs (~> 2.0)
      sprockets (>= 2.0.0)
      tilt (>= 1.2)
    i18n (0.9.5)
      concurrent-ruby (~> 1.0)
    i18n-debug (1.1.1)
      i18n (< 2)
    io-like (0.3.0)
    jbuilder (2.7.0)
      activesupport (>= 4.2.0)
      multi_json (>= 1.2)
    jquery-rails (4.3.3)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (6.0.1)
      railties (>= 3.2.16)
    js-routes (1.4.4)
      railties (>= 3.2)
      sprockets-rails
    json (2.1.0)
    kaminari (1.1.1)
      activesupport (>= 4.1.0)
      kaminari-actionview (= 1.1.1)
      kaminari-activerecord (= 1.1.1)
      kaminari-core (= 1.1.1)
    kaminari-actionview (1.1.1)
      actionview
      kaminari-core (= 1.1.1)
    kaminari-activerecord (1.1.1)
      activerecord
      kaminari-core (= 1.1.1)
    kaminari-core (1.1.1)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    loofah (2.2.2)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.0)
      mini_mime (>= 0.1.1)
    marcel (0.3.2)
      mimemagic (~> 0.3.2)
    method_source (0.9.0)
    mimemagic (0.3.2)
    mini_mime (1.0.0)
    mini_portile2 (2.3.0)
    minitest (5.11.3)
    msgpack (1.2.4)
    multi_json (1.13.1)
    net-scp (1.2.1)
      net-ssh (>= 2.6.5)
    net-ssh (5.0.1)
    nio4r (2.3.1)
    nokogiri (1.8.2)
      mini_portile2 (~> 2.3.0)
    non-stupid-digest-assets (1.0.9)
      sprockets (>= 2.0)
    originator (3.1)
      actionpack (>= 4.0)
      activerecord (>= 4.0)
    orm_adapter (0.5.0)
    polyamorous (1.3.3)
      activerecord (>= 3.0)
    popper_js (1.12.9)
    public_suffix (3.0.2)
    puma (3.11.3)
    rack (2.0.5)
    rack-cache (1.8.0)
      rack (>= 0.4)
    rack-test (1.0.0)
      rack (>= 1.0, < 3)
    rails (5.2.0)
      actioncable (= 5.2.0)
      actionmailer (= 5.2.0)
      actionpack (= 5.2.0)
      actionview (= 5.2.0)
      activejob (= 5.2.0)
      activemodel (= 5.2.0)
      activerecord (= 5.2.0)
      activestorage (= 5.2.0)
      activesupport (= 5.2.0)
      bundler (>= 1.3.0)
      railties (= 5.2.0)
      sprockets-rails (>= 2.0.0)
    rails-assets-OwlCarousel2 (2.3.3)
      rails-assets-jquery (>= 1.8.3)
    rails-assets-jquery (3.3.1)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.0.4)
      loofah (~> 2.2, >= 2.2.2)
    rails-i18n (5.1.1)
      i18n (>= 0.7, < 2)
      railties (>= 5.0, < 6)
    railties (5.2.0)
      actionpack (= 5.2.0)
      activesupport (= 5.2.0)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (12.3.1)
    ransack (1.8.8)
      actionpack (>= 3.0)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      i18n
      polyamorous (~> 1.3.2)
    rb-fsevent (0.10.3)
    rb-inotify (0.9.10)
      ffi (>= 0.5.0, < 2)
    recaptcha (4.8.0)
      json
    redis (4.0.1)
    redis-actionpack (5.0.2)
      actionpack (>= 4.0, < 6)
      redis-rack (>= 1, < 3)
      redis-store (>= 1.1.0, < 2)
    redis-activesupport (5.0.4)
      activesupport (>= 3, < 6)
      redis-store (>= 1.3, < 2)
    redis-rack (2.0.4)
      rack (>= 1.5, < 3)
      redis-store (>= 1.2, < 2)
    redis-rack-cache (2.0.2)
      rack-cache (>= 1.6, < 2)
      redis-store (>= 1.2, < 2)
    redis-rails (5.0.2)
      redis-actionpack (>= 5.0, < 6)
      redis-activesupport (>= 5.0, < 6)
      redis-store (>= 1.2, < 2)
    redis-store (1.5.0)
      redis (>= 2.2, < 5)
    request_store (1.4.1)
      rack (>= 1.4)
    responders (2.4.0)
      actionpack (>= 4.2.0, < 5.3)
      railties (>= 4.2.0, < 5.3)
    ruby_dep (1.5.0)
    rubyzip (1.2.1)
    sass (3.5.5)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    sass-rails (5.0.7)
      railties (>= 4.0.0, < 6)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    select2-rails (3.5.10)
      thor (~> 0.14)
    selenium-webdriver (3.12.0)
      childprocess (~> 0.5)
      rubyzip (~> 1.2)
    simple_form (4.0.1)
      actionpack (>= 5.0)
      activemodel (>= 5.0)
    spring (2.0.2)
      activesupport (>= 4.2)
    spring-watcher-listen (2.0.1)
      listen (>= 2.7, < 4.0)
      spring (>= 1.2, < 3.0)
    sprockets (3.7.1)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sqlite3 (1.3.12)
    sshkit (1.16.1)
      net-scp (>= 1.1.2)
      net-ssh (>= 2.8.0)
    stackose (0.1.1)
      capistrano (~> 3.7)
    thor (0.20.0)
    thread_safe (0.3.6)
    tilt (2.0.8)
    turbolinks (5.1.1)
      turbolinks-source (~> 5.1)
    turbolinks-source (5.1.0)
    tzinfo (1.2.5)
      thread_safe (~> 0.1)
    uglifier (4.1.11)
      execjs (>= 0.3.0, < 3)
    warden (1.2.7)
      rack (>= 1.0)
    web-console (3.6.2)
      actionview (>= 5.0)
      activemodel (>= 5.0)
      bindex (>= 0.4.0)
      railties (>= 5.0)
    websocket-driver (0.7.0)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.3)
    xpath (3.1.0)
      nokogiri (~> 1.8)

PLATFORMS
  ruby

DEPENDENCIES
  airbrake (~> 5.0)
  alchemy-devise!
  alchemy_cms (~> 4.1.0.rc1)
  bootsnap (>= 1.1.0)
  bootstrap (~> 4.0.0.beta3)
  bourbon
  byebug
  capistrano
  capistrano-db-tasks
  capybara (>= 2.15, < 4.0)
  chromedriver-helper
  coffee-rails (~> 4.2)
  cookie_law
  font-awesome-rails
  friendly_id (~> 5.2, >= 5.2.4)
  i18n-debug
  jbuilder (~> 2.5)
  jquery-rails
  jquery-ui-rails
  js-routes
  listen (>= 3.0.5, < 3.2)
  puma (~> 3.11)
  rails (~> 5.2.0)
  rails-assets-OwlCarousel2!
  rails-i18n (~> 5.1)
  recaptcha
  redis-rack-cache
  redis-rails
  sass-rails (~> 5.0)
  selenium-webdriver
  spring
  spring-watcher-listen (~> 2.0.0)
  sqlite3
  stackose (~> 0.1.1)
  turbolinks (~> 5)
  tzinfo-data
  uglifier (>= 1.3.0)
  web-console (>= 3.3.0)

RUBY VERSION
   ruby 2.4.0p0

BUNDLED WITH
   1.15.3

Possible Solution

pass the locals to render_element as duplicated hash

def render_element_view_partials(elements, options = {})
      buff = []
      elements.each_with_index do |element, i|
        buff << render_element(element, :view, options.dup, i + 1)
      end
      buff.join(options[:separator]).html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants