github.com

...page to visitors. Disables your application's web interface by writing a #{maintenance_basename}.html file to each web server. By default, the maintenance page will just say the site...

cap maintenance:disable Makes the application web-accessible again. Removes the #{maintenance_basename}.html page generated by maintenance:disable, which will make your application web-accessible again.

...you click on is not necessarily a link or button, but could be any HTML element with a Javascript event binding. The easiest way to get this step is to...

By default Middleman generates files with a .html extension. Because of this all your URLs end in /foo.html instead of /foo, which looks a bit old school. To get prettier...

...slash), then the browser makes a second request to /foo/ to retrieve the actual HTML. You can probably fix this by configuring your static web server. What we want is...

If you're using the :header_html option in PDFKit (or the corresponding --header-html option in wkhtmltopdf), and the header remains invisible, you need to add this to your...

The same applies to footers via footer_html

blog.mailgun.com

Styling HTML email is painful. Tables, inline CSS, unsupported CSS, desktop clients, web clients, mobile clients, various devices, various providers. All these things have to be thought about and tested...

github.com

...und dein Nebensatz." >> " und mein Nebensatz."} Formatting Standard formatting is :ascii. You also have :html and :color formatting: diff = Differ.diff "foo", "boo" puts diff.format_as :html # => boo foo puts diff.format...

superuser.com

Inspecting the source of an email does not always reveal the plain HTML source, but some encoded byte mess. In order to inspect the HTML anyways, you can use a...

While composing a message, select all (Ctrl + A), then navigate to Insert > HTML on the message window. If you need to inspect a received message, hit "Reply" to...

...classes Page and Template. Both contain the same behavior: They have a string field #html which needs to be sanitized (stripped of malicious HTML) before validation: # app/models/page.rb class Page < ApplicationRecord...

...before_validation :sanitize_html private def sanitize_html self.html = Sanitize.clean(html) end end # app/models/template.rb class Template < ApplicationRecord before_validation :sanitize_html private def sanitize_html self.html = Sanitize.clean(html) end

...more intuitive workflow when working with nested attributes in Rails + Unpoly: Without JS With HTML template and JS With HTML template and JS using dynamic Unpoly templates Adding Records via...

= task_form.check_box :_destroy = task_form.label :_destroy, "Remove task" = form.submit Adding nested records via template HTML with JS resources :variant_2_users, only: [:edit, :update] class Variant2UsersController < ApplicationController def edit

Internet Explorer 5+ is aware of conditional comments that let you target HTML for selected versions of IE. For example the HTML below would ask users of IE 6 and...

...a{ :href => 'http://www.mozilla.com/en-US/firefox/' }= 'Firefox' Sometimes you may need to insert semi-conditional HTML that is ignored by IE but interpreted by real browsers, like: <%= stylesheet_link_tag 'screen...

github.com

...but you can always just call Oj.dump explicitely). Security warning: Oj does not escape HTML entities in JSON Be aware that Oj.dump is not aware of ActiveSupport's escape_html...

...you can wrap the output of Oj.dump(...) in an escape_json tag to escape HTML entities in Strings: myFunction(<%= escape_json OJ.dump(@data) %>) Earlier Rails versions have an unusable implementation of escape_json (it deletes...

...an arbitrary route in your Rails application that is able to respond with regular HTML and JSON. By sending the specific MIME type in the Accept header, you tell the...

...application to either return HTML (text/html) or JSON (text/json). The problem is that Rails caches the response independently from the specified Accept header. This means that the first request made...

...this easily by using the lang attribute in your views (ERB): ... or in HAML: %html :xmlns => "http://www.w3.org/1999/xhtml", :"xml:lang" => I18n.locale || 'en', :lang => I18n.locale || 'en' Then, in your stylesheet...

...example declare different background-images for all the languages and elements that are involved. html[lang='en'] #header background-image: url(images/header_en.png) html[lang='de'] #header background-image: url(images/header_de.png...

You know those helper methods that just render some HTML but look weird because of content_tags all over the place? You could also use Haml instead. Example

...following helper. def greeting message = ''.html_safe message << 'Welcome to ' message << content_tag(:span, Rails.env, class: 'greeting--location') content_tag :div, message, class: 'greeting' end That looks clumsy and is...

...re-render the view for unchanged content, you don't need to send unchanged HTML over the network. Tip With the default ETag you don't need to care what...

...most Rails application layouts insert randomly rotating CSRF tokens and CSP nonces into the HTML, two requests for the same data state will never produce the same response bytes: ... ... ...

...note = '\u266A' You can use Unicode escape sequences in both single and double quotes. HTML Use an entity: &#x266a; Ruby 1.9+ In modern Rubies you can use the \u escape...

matthewphillips.info

...single tweet in fact, can be used to allow defining custom elements purely in HTML. This post will expand on the idea, show how the snippet works, and argue for...

...want to actually use this. A nice trick that lets you define "partials" in HTML without any additional rendering technology on the server or client...

In a web application you often need to move data between the client (HTML, Javascript) and the server (Ruby, Rails). Step 1: Moving HTML snippets Add a find-as-you...

...search results should happen on the server. So the client is pulling snippets of HTML from the server. For the part of the implementation that lives in Javascript, implement a...

Awesome hack by Tim VanFosson:

makandra dev
select2.org

...select2 input, you can populate it via AJAX in order to not pollute your HTML with lots of elements. All you have to do is to provide the collection in...

You know that you can use jQuery's text() to get an element's contents without any tags.

HAML SASS helpers partials When done, everything is simply compiled to static HTML and CSS, so no need to install anything on your server. If you receive an...

...it is not available for format determination and Rails will set the format to html. Unfortunately, the constraint won't complain in this case and Rails even renders the sitemap.builder...

Under certain (unknown) circumstances, Rails will give localized files an invalid content-type in the Response header. For me, after...