...is a great enhancement when you want users to supply some kind of code (HTML, JavaScript, Ruby, etc). It offers syntax highlighting and some neat features like auto-indenting.
...Unpoly compiler that will improve your : import ace from 'brace' import 'brace/mode/html' import 'brace/theme/monokai' up.compiler('[html-editor]', ($element) => { let $editorContainer = $(' ').insertAfter($element) let editor = ace.edit($editorContainer.get(0)) let session = editor.getSession...
...reconfiguring your Rails app so two requests to the same resource produce the same HTML for a given user...
...breaking to force it appear) that would usually separate them. We're trimming the HTML of the element that should not be truncated so that we don't end up...
...a property of the isolate scope to a function in the parent scope. Example: # HTML # Coffeescript @app.directive 'panel', -> scope: parentFn: '&proxy' link: (scope) -> scope.parentFn(arg1: 'first', arg2: 'second')
...know the arguments to pass to that function? Defining plain function arguments in the HTML Luckily Angular supports plain values in the proxy definition in the HTML, and even a...
...file to the asset pipeline. Require it in your application.js: #= require clipboard Prepare your html: Your copy-to-clipboard-button either needs a data-clipboard-target attribute with a selector...
...tooltip(title: tooltipText()) .tooltip('show') .on 'hidden.bs.tooltip', -> $button.tooltip('destroy') tooltipText = -> text = "" if isOnMacOS() language = $('html').attr('lang') text = if language == 'de' '⌘-C zum Kopieren drücken' else 'Press ⌘-C to copy...
...you can use that as well, though it has no extra benefit: :001 > Nokogiri::HTML("This is beautiful markup ").text.gsub(/[^[:word:]]+/, " ") => "This is beautiful markup" DANGER, WILL ROBINSON: Both solution...
:001 > ActionController::Base.helpers.strip_tags("<<<<YY<>>NASTY><s<<>s>") => "<<<<>>NASTY><<>s>" :002 > Nokogiri::HTML("<<<<YY<>>NASTY><s<<>s>").text => ">NASTY>s>" :003 > ActionController::Base.helpers.strip_tags("<<<<YY<>>NASTY><s<<>s...
When a Rails controller action should handle both HTML and JSON responses, do not use request.xhr? to decide that. Use respond_to. I've too often seen code like this...
# ... if request.xhr? render json: @user.as_json else # renders default HTML view end end This is just plain wrong. Web browsers often fetch JSON via XHR, but they (should...
...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...
...a profile for each of them. In this case you can use a vanilla HTML link to a prefilled "share" form on Twitter, Google+ and Facebook. Use the URL templates...
...fill out a short form and get a Javascript snippet to copy/paste into your HTML: Facebook like button Google +1 button Twitter buttons Unfortunately just having the untuned buttons sit...
...site requesting silly formats like: http://www.rails-app.com/makandra.html-username-2000 # => Rails tries to retrieve 'makandra' with format 'html-username-2000' Just restrict accepted format parameters for the whole application like this:
before_filter :refuse_silly_formats private def refuse_silly_formats acceptable_formats = %w[html xml pdf] if params[:format] unless acceptable_formats.include? params[:format].downcase Rails.logger.error "Format not supported: #{params...
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...
...Chrome 65 with current Selenium-Webdriver (3.11) and chromedriver (2.37), where strings containing slashes (HTML) would be completely mangled...
...text snippet for Cucumber: When /^I fill in the "([^\"]+)" WYSIWYG editor with:$/ do |selector, html| patiently do page.execute_script("return isCkeditorLoaded('#{selector}');").should be_true end html.gsub!(/\n+/, "") # otherwise: unterminated...
...string literal (Selenium::WebDriver::Error::JavascriptError) page.execute_script("CKEDITOR.instances['#{selector}'].setData('#{html}');") end The snippet for JavaScript: function isCkeditorLoaded(instance_selector) { // instance_selector is e.g. 'template_html' var status;
.../while proxying, the proxied app will probably be broken: all absolute paths in your HTML's link hrefs point to the wrong URL any CSS that contains directives like background...
...Content_Type} =~ m|^application/javascript|" FilterChain NEWPATHS Note that code above isn't aware of HTML or CSS in any way, it does a brute find-and-replace. You can now...
...Checks if the page or current node has the given text content, ignoring any HTML tags and normalizing whitespace.` (Boolean) has_css?(path, options = {}) Checks if a given CSS selector...
...the page or current node does not have the given text content, ignoring any HTML tags and normalizing whitespace. (Boolean) has_no_css?(path, options = {}) Checks if a given CSS...
...else -- your IDE may even be aware of it, for example RubyMine understands <<-SQL, <<-HTML, <<-XML, <<-JSON, etc and highlights correctly. Please note: Your string will end with a new...
...you can just put your heredocs strings below each other. Example: def long_messages html_escape(<<-ONE) + ' ' + html_escape(<<-TWO) Here goes my first very long message. Yeehaw! ONE
...finished re-compiling, you will just reload the same old assets. When you render HTML without a dev server When you don't have a dev server running and call...
...executed after the DOM has loaded completely. That means when the browser has finished HTML parsing and built the DOM tree. At that time, you can manipualte the DOM although...
...though the element(s) you would like to manipulate exist(s) in the delivered HTML. So you should always encapsulate DOM-manipulating javascript code in a DOM-loaded callback.
...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...
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
...tutorial doesn't show how to execute ruby-code that isn't rendered to HTML. To do this start a line with a dash ('-') instead of the equals-sign...
...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...
...with the width and the div should only have the height of the picture. html: css: .outer { width: 100%; background-image: image-url('background.png'); background-size: cover; } .inner {
...you only depend on the width of the viewport, you can also use vw: html: css: .background-sizer { width: 100%; height: 60vw; background-image: image-url('background.png'); background-size: cover...
...with isolate scopes have three different variable binding strategies, of which one is =. Example: # HTML # Coffeescript @app.directive 'panel', -> scope: evaluated: '=value' bound: '=twoway' link: -> scope.evaluated # = false scope.bound = 'foo' # Updates parent.someProperty...
...HTML attributes bound with = (value, twoway) have their value evaluated as Angular expression in the parent scope's context and have the result assigned to the corresponding scope variable (evaluated...