capybara_element['attribute_name'] allows accessing an element's attributes in Capybara. A few examples: find('#my_element')['class']
Browsers can auto fill-in one time codes if advised. Use it like this: Demo: https://twitter.com/sulco/status/1320700982943223808 Browser support...
A comprehensive introduction to sending HTML emails. Intro: HTML email: Two words that, when combined, brings tears to a developer’s eyes. If you’re a web developer, it’s...
...lap at some time in your career, whether you like it or not. Coding HTML email is old school. Think back to 1999, when we called ourselves “webmasters” and used...
...keep your well-structured CSS files and do the inlining for you. See Designing HTML email Since Roadie is now in passive maintenance mode, we go with premailer: Include premailer...
...tag attachments['logo.png'].url, alt: 'Company logo', width: 100 %> Note: You should set the html width and/or height attribute as shown above, because most of the e-mail clients can...
...they want their tables back. Unfortunately, you need them all for laying out your HTML emails. Email client HTML rendering is way more scattered than browser HTML. While you might...
...can use to support all major browsers, I doubt anyone masters this craft for HTML email clients. The only way to ensure your email looks good (acceptable, at least) in...
...JavaScript, and put this into your application.js: $(function() { $('[data-remote][data-replace]') .data('type', 'html') .live('ajax:success', function(event, data) { var $this = $(this); $($this.data('replace')).html(data); $this.trigger('ajax...
...helper, use the following code instead: $.unobtrusive(function() { $('[data-remote][data-replace]') .data('type', 'html') .live('ajax:success', function(event, data) { var $this = $(this); $($this.data('replace')) .html(data) .activateUnobtrusiveJavascript(); $this.trigger...
...Chrome 65 with current Selenium-Webdriver (3.11) and chromedriver (2.37), where strings containing slashes (HTML) would be completely mangled...
...non-default behavior that you know from other tags. Do not try to style html or body for positioning, width/heigth, or similar. Every browser has its own caveats and you...
...can not test them all. Generally speaking: Use the html tag to define your page's default background color (because on short pages or large screens, your body may not...
tl;dr In Chrome DevTools in the Elements tab or in Firefox in the Inspector tab you can right click...
...a simple change. Note that Devise's default configuration actually only redirects requests for HTML content (as requested by the HTTP Accept header). For all other formats (like JSON) it...
...config.http_authenticatable = true config.navigational_formats = [] You may want to also disable routes to the HTML forms in your routes.rb: devise_for :users, skip: [:sessions] # or skip: :all to also disable...
Use the htmlentities gem. Encoding works like this: require 'htmlentities' coder = HTMLEntities.new string = "<élan>" coder.encode(string) # => "<élan>" coder.encode(string, :named) # => "<élan>" coder.encode(string, :decimal...
coder.encode(string, :hexadecimal) # => "<élan>" Decoding works like this: require 'htmlentities' coder = HTMLEntities.new string = "élan" coder.decode(string) # => "élan...
If you are using Angular and want something like Rails' simple_format which HTML-formats a plain-text input into paragraphs and line breaks, this directive is for you.
...HTML fragments inside that text will still be escaped properly. Use it like this, where your text attribute specifies something available in your current scope: This is the directive, in...
...partials to call yield. You can use this to extract common containers in your HTML. # _card.html.erb <%= yield %> # index.html.erb <%= render partial: 'card' do %> This is card content <% end %> Using yielding partials...
...Partials vs. Helpers I recommend to avoid using helpers when rendering large chunks of html and go for a partial instead. If your helper method requires a large chunk of...
...xml = Nokogiri::XML(" foo bar ") parses an xml string. You can also call Nokogiri::HTML to be more liberal about accepting invalid XML. xml / 'list item' returns all matching nodes...
If you want to convert a README.rdoc file to HTML, say this from a shell: rdoc README.rdoc You will find the generated HTML in doc/index.html. If you do this while...
...of our gems, please .gitignore everything in doc and don't commit the generated HTML...
...using ASCII art, but you can also make it send those notification as simple HTML e-mails that have some simple formatting for clarity, but no images etc. To do...
...so, activate this option: :email_format => :html Those HTML notifications are still delivered with a text-only version, so if you are using a console client or want to forward...
If you need to test some HTML, e.g. an embed code, you can use RubyMine's "scratch files": File > New Scratch File (or Ctrl + Shift + Alt + Ins) Select "HTML" as...
Write or paste the HTML Move your mouse to the upper right corner of the scratch file editor. Pick a browser to instantly open your file...
...support for passing a block (which could e.g. render a "read on" link), and html_safe knowledge. Prefer the truncate() helper Warning: truncate() calls html_safe if you're not...
...escaping. FWIW, an HTML string may easily become invalid when truncated, e.g. when a closing tag gets chopped off. However, when the input string is "fully html safe", i.e. contains...
...When you append a String to a SafeBuffer (by calling + or <<), that other String is HTML-escaped before it is appended to the SafeBuffer: " ".html_safe + " " # => " <bar>"
...your views to it. This means that any <%= expression %> in your view template will be HTML-escaped, unless the expression returns a SafeBuffer, which does not need to be escaped...
lambda { webrat.current_scope.send(:locate_field, name) }.should raise_error(Webrat::NotFoundError) end Find html content Then /^I should see "([^\"]*)" in the HTML$/ do |text| response.body.should include(text) end
...I should not see "([^\"]*)" in the HTML$/ do |text| response.body.should_not include(text) end Find html content within a selector Then /^I should see "([^\"]*)" in the HTML within "([^\"]*)"$/ do |text...
If a controller action responds to other formats than HTML (XML, PDF, Excel, JSON, ...), you can reach that code in a controller spec like this: describe UsersController do describe '#index...
...most Rails application layouts insert randomly rotating CSRF tokens and CSP nonces into the HTML, two requests for the same content and user will never produce the same response bytes...
Tooltips that are delivered through HTML attributes are encoded. Decode entities before checking for their presence. Capybara: Then /^there should( not)? be a(n encoded)? tooltip "([^"]*)"$/ do |negate, encoded, tooltip...
...tooltip = HTMLEntities.new.encode(tooltip) if encoded Then "I should#{negate} see \"#{tooltip}\" in the HTML" end Note This step uses the htmlentities gem described in another card. Make sure you require...
Nobody needs HTML e-mails. However, you occasionally might have to write an HTML message for some weird reason. Here is how: Hold the Shift-Key while clicking on "Write...