Git Product home page Git Product logo

arbre's Introduction

Arbre - HTML Views in Ruby

Arbre makes it easy to generate HTML directly in Ruby. This gem was extracted from Active Admin.

Version         Github Actions  Tidelift

Goals

The purpose of Arbre is to leave the view as ruby objects as long as possible. This allows OO Design to be used to implement the view layer.

Getting started

Need help?

Please use StackOverflow for help requests and how-to questions.

Please open GitHub issues for bugs and enhancements only, not general help requests. Please search previous issues (and Google and StackOverflow) before creating a new issue.

Want to support us?

Subscribe to Tidelift to support Arbre and get licensing assurances and timely security notifications.

Security contact information

Please use the Tidelift security contact to report a security vulnerability. Tidelift will coordinate the fix and disclosure.

arbre's People

Contributors

ahorek avatar alejandroperea avatar aramvisser avatar chipairon avatar deivid-rodriguez avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar dlackty avatar dtaniwaki avatar fivell avatar gregbell avatar imacubsfan23 avatar javierjulio avatar kaapa avatar knoopx avatar lte avatar mergify[bot] avatar ngan avatar olleolleolle avatar peeja avatar seanlinsley avatar shekibobo avatar strivedi183 avatar tagliala avatar timoschilling avatar tomascco avatar tommy-gilligan avatar utkarsh2102 avatar varyonic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arbre's Issues

Arbre sometimes does not render collections

Ok. This is one of stranger bugs out there. I'm not sure where should I add it since I think ARBRE is at fault but the bug originates in active admin.

Anyway. sometimes yes, only sometimes activeadmin will jsut render blank page (on some pages like dashboard), and sometimes it'll raise ArgumentError, "Can't be in the context of nil. #{@_current_arbre_element_buffer.inspect}"

I tried to debug this thing for hours now. and I think the problem is somewhere between this call from Builder: https://github.com/gregbell/arbre/blob/master/lib/arbre/element/builder_methods.rb#L60
and add_child oimplementation https://github.com/gregbell/arbre/blob/master/lib/arbre/element.rb#L34

I have no idea why Array of elements is converted into text node, then converted back to element.

Either way the result is that sometimes the array of rows in tbody instead of beeing added as children gets added as a string as first element.

Override `p`

Arbre uses para for <p> tags because p is a Ruby method, similar to puts. I understand the unwillingness to override Ruby methods, but I think it's less surprising than requiring people to read the Arbre documentation in order to create paragraph tags.

I propose that we release a final version for 1.x (1.99) that:

  • warns that behavior will change for p
  • deprecates para

As well, that we immediately release a 2.0 version with the method renamed from para to p.

can't create custom components

i've created simple rails project
put gem 'arbre' into Gemfile
create file app/lib/arbre_components/panel.rb:

module ArbreComponents
  class Panel < Arbre::Component
    builder_method :panel

    def build(title, attrs = {})
      super(attrs)
      h3 title, class: 'panel-title'
    end
  end
end

generate controller with rails g Welcome index and set it to root
and change text in app/views/welcome/index.html.erb:

<%= Arbre::Context.new { panel 'welcome' } %>

on page render i get an error:

Started GET "/" for 127.0.0.1 at 2015-08-27 20:23:55 +0300
Processing by WelcomeController#index as HTML
  Rendered welcome/index.html.erb within layouts/application (4.1ms)
Completed 500 Internal Server Error in 21ms (ActiveRecord: 0.0ms)

ActionView::Template::Error (undefined method `panel' for :Arbre::Context):
    1: <%= Arbre::Context.new { panel 'welcome' } %>
  app/views/welcome/index.html.erb:1:in `block in _app_views_welcome_index_html_erb__3263134319601290878_43964100'
  app/views/welcome/index.html.erb:1:in `new'
  app/views/welcome/index.html.erb:1:in `_app_views_welcome_index_html_erb__3263134319601290878_43964100'


  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/actionpack-4.2.3/lib/action_dispatch/middleware/templates/rescues/_source.erb (15.7ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/actionpack-4.2.3/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (3.7ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/actionpack-4.2.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.2ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/actionpack-4.2.3/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (39.6ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/_markup.html.erb (0.5ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.5ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.4ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.5ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/console.js.erb within layouts/javascript (20.9ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/main.js.erb within layouts/javascript (0.4ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.5ms)
  Rendered /home/senid/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/index.html.erb (44.9ms)

what have i done wrong?)

Use streaming responses

See activeadmin/activeadmin#2689

The unused in-memory DOM representation more than doubles the memory usage required to service a request and complicates the implementation to having a seperate buffer per element. I think a lot can be gained my dropping the in memory DOM representation: a single ActionView buffer can be passed from parent to child, lowering memory usage and allow us to use streaming responses.

Arbre::Element: method_missing without respond_to?

It breaks activeadmin scenarios like

ActiveAdmin.register Something do
  action_item :children do # action_item without something like only: [:show, :edit]
    link_to 'Update children', some_path(something) if respond_to?(:something)
  end
end

however naive respond_to_missing? for Arbre::Element seems to cause infinite recursion

    def respond_to_missing?(name, _include_all)
      (current_arbre_element != self && current_arbre_element.respond_to?(name)) ||
          !!(assigns && assigns.has_key?(name)) ||
          helpers.respond_to?(name) ||
          super
    end

can i use helper methods that use arbre in *.arb templates ?

example that does not work:

app/helpers/application_helper.rb

module ApplicationHelper
  def arbre(&block)
    Arbre::Context.new({}, self, &block)
  end

  def static_pie_chart(data)
    arbre do
      div class: 'd3-pie-chart', 'data-series': data
    end
  end
end

app/views/dashboard/index/html.arb

h1 'Dashboard#index'
static_pie_chart [{label: 'first', value: 23}, {label: 'second', value: 46}]

and it's same as:

h1 'Dashboard#index'
Arbre::Context.new({}, self) do
  div class: 'd3-pie-chart', 'data-series': [{label: 'first', value: 23}, {label: 'second', value: 46}]
end

and this is doesn't work. div with class 'd3-pie-chart' doesn't appear in rendered html because context that executes *.arb file just ignore new Arbre::Context

example that works but not like i want №1:

app/helpers/application_helper.rb

module ApplicationHelper
  def arbre(&block)
    Arbre::Context.new({}, self, &block)
  end

  def static_pie_chart(data)
    arbre do
      div class: 'd3-pie-chart', 'data-series': data
    end
  end
end

app/views/dashboard/index/html.arb

h1 'Dashboard#index'
div do
  text_node static_pie_chart([{label: 'first', value: 23}, {label: 'second', value: 46}])
end

it works because text_node convert first parameter into string
but i don't want to wrap each method into text_node

example that works but not like i want №2:

app/helpers/application_helper.rb

module ApplicationHelper
  def arbre(&block)
    Arbre::Context.new({}, self, &block).to_s
  end

  def static_pie_chart(data)
    arbre do
      div class: 'd3-pie-chart', 'data-series': data
    end
  end
end

app/views/dashboard/index/html.arb

h1 'Dashboard#index'
div do
  static_pie_chart [{label: 'first', value: 23}, {label: 'second', value: 46}]
end

it works because static_pie_chart returns html_safe string
but i don't want to wrap every method into div or span

question

how can i write helper methods if i want them to return child elements of current context?

problem with yield in layout

i create controller app/controllers/test_controller.rb

class TestController < ApplicationController
  layout 'application'
  def index
  end
end

replace layout app/viewslayouts/application.html.arb

html do
  head do
    title 'Test'
    text_node (stylesheet_link_tag    'application', 'data-turbolinks-track' => true, media: 'all')
    javascript_include_tag 'application', 'data-turbolinks-track' => true
    text_node csrf_meta_tags
  end

  body do
    para 'before content'
    yield
    para 'after content'
  end
end

and add template app/views/test/index.html.arb

h1 'index'

but when i load page it generates output body like:

<body>
    <p>before content</p>
    <p>after content</p>
</body>

but when i change app/viewslayouts/application.html.arb like

html do
  head do
    title 'AdminLTE Arbre'
    text_node (stylesheet_link_tag 'application', 'data-turbolinks-track' => true, media: 'all')
    javascript_include_tag 'application', 'data-turbolinks-track' => true
    text_node csrf_meta_tags
  end

  body do
    para 'before content'
    div { yield }
    para 'after content'
  end
end

yield works correct

<body>
    <p>before content</p>
    <div>
        <h1>index</h1>
    </div>
    <p>after content</p>
</body>

there is no such problem with erb templates

Arbre deletes attribute :for of html label tag

This line in lib/arbre/html/tag.rb:

    set_for_attribute(attributes.delete(:for))

makes it difficult to define custom label tag using arbre html tag. Currently I'm creating a custom page to edit system settings. The settings are just entries in the database so I need to print label and input manually.

License

Hello Greg,

we've just upgraded ActiveAdmin to 0.5. We'd like to ensure that the license still is MIT, and this implies that all ActiveAdmin dependencies are MIT (or compatible) licenses too.

Could you please add the license to this gem?

Thank you,

r.

Document usage of .arb files

I just stumbled upon this awesome feature. I didn't realize you could create template files with .arb extension, and it would set up the Arbre context. This should be added to the documentation.

Using Arbre in ERB, how to access the ERB context?

# show.html.erb

@username = 333

html = Arbre::Context.new do
  h2 "hello #{@username.to_s}"
end

concat html.to_s

It outputs

   hello 

Clearly the value @username defined outside is not accessible. How to fix that?

Nested Form Fields Rendered Twice in 1.2.0 Release

After upgrading to the latest activeadmin and arbre, we realized that our nested form fields are being duplicated in our templates.

  • activeadmin 1.3.1
  • arbre 1.2.0
  • rails 5.2.3
  • ruby 2.3.6

Example form for ActiveAdmin resource:

ActiveAdmin.register Drawer do
  form do |f|
    columns do
      column do
        panel 'Payment Methods' do
          table do
            thead do
              th 'Payment Method'
              th 'Amount Processed'
              th 'Expected on Hand'
            end

            tbody do
              f.semantic_fields_for :payments do |payments|
                tr(class: cycle('odd', '')) do
                  td(class: 'hidden') { payments.input :id, as: :hidden }
                  td { payments.object.payment_method.name }
                  td { payments.object.amount_processed.format }
                  td { payments.object.amount_expected_on_hand.format }
                end
              end
            end
          end
        end
      end
    end
  end
end

We end up with the semantic_fields_for rendering double the amount of rows, a whole group and then the entire collection again a second time.

Leaving activeadmin and rails locked to the versions mentioned above, but downgrading to arbre version 1.1.1 (the previous release) fixes the issue.

using link_to with block in arbre template

index.html.arb with such code

h1 'Dashboard#index'
para 'Find me in app/views/dashboard/index.html.arb'
link_to sign_out_path, data: {confirm: 'Are you sure?'}, method: :delete do
  i 'Logout', class: 'fa fa-lock'
end

generate incorrect html

<h1>Dashboard#index</h1>
<p>Find me in app/views/dashboard/index.html.arb</p>
<i class="fa fa-lock">Logout</i>

i can use text_node only if i use link_to without block

text_node link_to('Logout', sign_out_path, method: :delete).html_safe
<a rel="nofollow" data-method="delete" href="/sign_out">Logout</a>

i think same situation will be with any helper method with block that returns html

Time for a release?

Hi,

There have been 57 commits so far since the last release, perhaps time for another one?

Spec Tests using to_be_success predicate are being deprecated

I'm new here, and looking for a way to contribute to this seemingly useful gem.

I noticed after forking the repo that rspec is deprecating "to_be_success" in rails 6.0, and I would like to change it to its updated version of "to_be_successful"

Bump the gem version

The official gem version is very old and there have been some important fixes commited in the meantime.

Could you please bump to 1.0.2?

question: How can I wrap component with another in custom component class

for example I want to write code like this:

my_custom_sidebar class: 'additional', wrapper_html: {id: 'custom-id'} do
# standard arbre tags
end

and get html:

<aside class="aside-wrapper" id="custom-id">
  <section class="sidebar additional">
    <!-- some other tags -->
  </section>
</aside>

how can i do it?

I tried to do it like this

module ArbreCustom
  class ArbreSidebar < Arbre::Component
    builder_method :arbre_sidebar
    attr_accessor :wrapper_aside

    def tag_name
      :section
    end

    def build(options = {})
      aside_wrapper_options = options.delete(:aside_html) || {}
      within parent do
        @wrapper_aside = aside(aside_wrapper_options)
        @wrapper_aside.add_class('aside-wrapper')
      end
      within @wrapper_aside do
        super(options)
      end
    end

    protected

    def default_class_name
      'sidebar'
    end

  end
end

but all i get was:

<aside class="aside-wrapper" id="custom-id"></aside>
<section class="sidebar additional">
  <!-- some other tags -->
</section>

Arbre Rails gem

We should extract the Rails part of Arbre in to a new gem.

We could build a better solution for #43 and #38.

Support for custom elements with hyphenated tag names

Just started to play around with Arbre, and something I noticed right off the bat is it doesn't have out-of-the-box support for custom elements. Since that's part of the HTML spec, seems to me there should be a way to support it.

I wrote a little wrapper Arbre component which might help kick off discussion:

class CustomElement < Arbre::Component
  builder_method :custom

  def build(tag_name, *args, **kwargs)
    @tag_name = tag_name.to_s.tr("_", "-")

    super(*args, **kwargs)
  end

  attr_reader :tag_name
end

Then you could just use it in your template:

custom :my_custom_component, "Wow, it works!", class: "something" do
  para "Very nice!"
end
<my-custom-component class="something"><p>Very nice!</p></my-custom-component>

Obviously people could write their own Arbre components to handle individual custom elements, which is pretty cool actually, but I think an out-of-the-box wrapper would be helpful to start.

Use Arbre as view file?

Is there a way in rails to have a index.html.arbre file that just automatically uses an Arbre context?

Force encoding (Incompatible character encodings: UTF-8 and Windows-1251)

Hello! When I try to output collection of elements with inconsistent encodings, I got the exception:

incompatible character encodings: UTF-8 and Windows-1251

Cause of the exception is

def to_s
self.collect do |element|
element.to_s
end.join('').html_safe
end
end

Is forcing of encoding in to_s method for all elements of collection before join is good idea? Or I should solve this problem in my application?

doctype in arbre layout

i get

undefined local variable or method `doctype' for :Arbre::Context

on rendering layout application.html.arb

doctype # this line
html do
  head do
    title 'AdminLTE Arbre'
    text_node (stylesheet_link_tag  'application', 'data-turbolinks-track' => true, media: 'all')
    javascript_include_tag 'application', 'data-turbolinks-track' => true
    text_node csrf_meta_tags
  end

  body do
    yield
  end
end

how can i add <!DOCTYPE html> to layout?

Using `br` produces two `<br>` tags in FF

Seems that arbre generates invalid markup for elements that should have no content. One of them is br

br produces <br></br> htm which for some reason Firefox interprets as 2 BR tags. While some fault is on FF side, above HTML is illegal, and i think arbre should not produce closing tags for stuff like br or input

Instance variables missing

It appears that instance variables aren't carrying over into the view. Despite this, they can still be accessed via the helpers object through method_missing. Now according to the code comments, helpers is supposed to instantiate... instance variables. Has this just not been implemented at the moment?

Currently there are two workarounds:

# Either
h3 helpers.user
# Or
h3 user

# Though this should work:
h3 @user

P.S. Instance variables worked fine when Arbre was still integrated into Active Admin

table_for and an array of hashes

Not sure if you wrote your own table_for or if you are using someone elses gem, but how would you make something like this work

table_for Professional.subscribed.map {|pro| {name_and_company: pro.name_and_company, number_referrals: pro.referrals.count}} do |pro|
        column ("Name") {|pro| pro[:name_and_company]}
        column ("Referrals") {|pro| pro[:number_referrals]}
      end

Where do you put the arbre code?

Where do you put the arbre code?

In activeadmin: app/admin/dashboard.rb for instance?

In the html.erb views?

Where do you put it?

Arbre context class respond_to? method issue

Arbre Context class' respond_to? method is not compatible with ruby 2.0 ... I am using few gems that make a call to context's respond_to with a method name and fail as they are trying ruby 2 syntax, respond_to?(symbol, include_all=false) ... which fails complaining about the number of arguments passed

Arbre helper for Rails

Example written from @seanlinsley on activeadmin/activeadmin#2874:

# app/helpers/application_helper.rb
module ApplicationHelper
  def arbre(&block)
    Arbre::Context.new(&block).to_s
  end
end

# app/decorators/foo_decorator.rb
class FooDecorator < Draper::Decorator
  def wheelchair
    arbre do
      status_tag model.wheelchair, class: model.wheelchair
    end
  end
end

The other option is to use a preinitialised instance that be dup for each call:

module ApplicationHelper
  def arbre_context
    @arbre_context ||= Arbre::Context.new
    @arbre_context.dup
  end

  def arbre(&block)
    arbre_context.instance_eval(&block).to_s
  end
end

dup is ~3 times faster that new

context = Arbre::Context.new
Benchmark.ips do |b|
  b.config(:time => 5, :warmup => 2)
  b.report("dup"){ context.dup }
  b.report("new"){ Arbre::Context.new }
  b.compare!
end
Calculating -------------------------------------
                 dup      1110 i/100ms
                 new      1026 i/100ms
-------------------------------------------------
                 dup   819778.0 (±10.9%) i/s -    3751800 in   4.650747s
                 new   284126.6 (±8.3%) i/s -    1367658 in   4.851749s

Comparison:
                 dup:   819778.0 i/s
                 new:   284126.6 i/s - 2.89x slower

Arbre::Element method_missing gives precedence to assigns instead of helpers

I am facing this issue where I need to access current_user method that is returning
different value as compared to @current_user.

in erb templates current_user helper method is invoked as expected and does the job as intended.

but in arb templates @current_user gets precedence through assigns array as it is coded here

def method_missing(name, *args, &block)

should not helper methods be getting precedence? as it is in erb templates also

Arbre duplicates form fields when inspecting model during production/debug

Moved from activeadmin/activeadmin#4639

Description

I came across this problem when building this activeadmin addon aiming to customize default ActiveAdmin layout by using CaptureHelper methods.

I'm getting repeated form fields when inspecting or evaluating arbre components related to forms. I didn't had problems with anything else but forms. Seems related to Arbre but couldn't find the bug yet.

Versions

activeadmin 1.0.0.pre4
rails 5.0.0.1.
ruby 2.3.0p0

Steps to reproduce

Take any ActiveAdmin resource that has a form declaration in its DSL and add a puts self.inspect before closing the block. You will get the form fields duplicated.

Example

I'll use the default admin_user Resource as an example:

ActiveAdmin.register AdminUser do
  permit_params :email, :password, :password_confirmation

  index do
    selectable_column
    id_column
    column :email
    column :current_sign_in_at
    column :sign_in_count
    column :created_at
    actions
  end

  filter :email
  filter :current_sign_in_at
  filter :sign_in_count
  filter :created_at

  form do |f|
    f.inputs "Admin Details" do
      f.input :email
      f.input :password
      f.input :password_confirmation
    end
    f.actions
    puts self.inspect
  end

end

Go to the edit or new route and you will get something like this:

image

Indent Perfomance

Hi. I see Arbre::HTML::Tag#indent in stackprof top and it confuses me.

  Mode: cpu(1000)
  Samples: 172 (0.00% miss rate)
  GC: 33 (19.19%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
        33  (19.2%)          33  (19.2%)     (garbage collection)
        29  (16.9%)          29  (16.9%)     ActiveSupport::SafeBuffer#initialize
        14   (8.1%)          13   (7.6%)     Arbre::Element#initialize
        11   (6.4%)          11   (6.4%)     Arbre::HTML::Attributes#value_empty?
        19  (11.0%)           8   (4.7%)     Arbre::HTML::Tag#indent
         7   (4.1%)           7   (4.1%)     ActiveSupport::Inflector#demodulize

I test this patch and got a 10% performance boost.
https://gist.github.com/alexesDev/343e22b45fac02fd7f509bb408874f66

Are indents really needed?

Unable to set the "for" attribute on tags

The :for option has special meaning in the Arbre library and is used to identify the ActiveModel associated with the tag. This prevents the for HTML attribute from being set via the Arbre DSL.

Below is an example of issue. The for attribute will not be set; instead the id and class attributes will be set.

form do
  label "Field Label", for: "text-field"
  input type: "text", id: "text-field"
end

How to add manifest tag in html tag.

Hi, i need to add manifest tag in html field. How to make it?
I override the tag_name in initialize, for activeadmin but a think this is a ugly way.

Template tag?

I was wondering if arbre supports the template tag.

As far as I understood, this tag is missing here:

AUTO_BUILD_ELEMENTS = [ :a, :abbr, :address, :area, :article, :aside, :audio, :b, :base,
:bdo, :blockquote, :body, :br, :button, :canvas, :caption, :cite,
:code, :col, :colgroup, :command, :datalist, :dd, :del, :details,
:dfn, :div, :dl, :dt, :em, :embed, :fieldset, :figcaption, :figure,
:footer, :form, :h1, :h2, :h3, :h4, :h5, :h6, :head, :header, :hgroup,
:hr, :html, :i, :iframe, :img, :input, :ins, :keygen, :kbd, :label,
:legend, :li, :link, :map, :mark, :menu, :menuitem, :meta, :meter, :nav, :noscript,
:object, :ol, :optgroup, :option, :output, :param, :pre, :progress, :q,
:s, :samp, :script, :section, :select, :small, :source, :span,
:strong, :style, :sub, :summary, :sup, :svg, :table, :tbody, :td,
:textarea, :tfoot, :th, :thead, :time, :title, :tr, :track, :ul, :var, :video, :wbr ]

Can we add it?

Specs failing because of Combustion

I'm not sure how to fix this, but since it's probably keeping this from an official release and thus preventing this from being fixed, it should at least be an open issue.

I know nothing of Combustion, but I tried a simple upgrade of the gem a while back and it appears to be a little more involved than just that.

Nested link generation

Hello
I try to do something like

                user_with_link = link_to(user.email, [:admin, user])
                h3 [user_with_link,  v.event,  l(v.created_at, format: :short)].join(', ')

and fails, becourse of geting "safe" first tag output and link writes in compile html like
<a href="/admin/admin_users/1">[email protected]</a>, create, 29 feb., 00:46

As you understand, i just want to have h3 tag, where part of it will be link.

I try out code like raw( "<h3>" + [user_with_link, v.event, l(v.created_at, format: :short)].join(', ') + "</h3>") but it was not good also.

h3 tad does not accept the block, so, i can not push sew different lines of code.

I tryed out to use text_node, but it also escape the output, outerway i loose the context.

How I can provide propper output in Arbre way?

Thank you

Custom helper methods aren't rendered in 1.2.0

As of version 1.2.0, this helper method no longer renders:

# _form.html.arb
active_admin_form_for [:admin, resource] do |f|
  error_banner(f)

  # ...
end
# app/helpers/admin/application_helper.rb
module Admin::ApplicationHelper
  def error_banner(form)
    # ...

    form.semantic_errors
  end
end

When inlining the code, however, it does render.

# _form.html.arb
active_admin_form_for [:admin, resource] do |f|
  f.semantic_errors

  # ...
end

This was likely caused by #64, and is related to #119.

It's not clear if the issue is specific to using Arbre templates (as opposed to inlined forms in app/admin), or using custom helper methods (as opposed to Rails helper methods).

Arbre Concatenation

What I want is the below, but weirdness ensues when mixing Arbre with strings all on the same line
Wee and Woo aren't required.

The first attempt errored out as it couldn't convert String to Array (for whatever reason)

span b("Wee") + " and " + b("Woo") + " aren't required."

The second almost worked...

span b("Wee") << " and " << b("Woo") << " aren't required."

...except it created this HTML output (cleaned up--wow was that messy)

<b> and  
  <b>Woo</b>
  aren't required.
</b>

<span>
  Wee
  <b>Woo</b>
  aren't required.
</span>

Now this gave me the correct visual effect.

span b("Wee") + " and " << b("Woo") << " aren't required."

Any idea what's happening?

Issue with adding html5 data attributes to div tag

I'm running into an issue when trying to add a data attribute to a div tag like so:
div id: 'some-id', data: { foo: 'bar' }
this outputs the following:
<div class="some-id" data="{:foo=>"bar"}"></div>

Other formatting attempts such as data-foo => "bar" are met with syntax errors.

Any thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.