Skip to content

Instantly share code, notes, and snippets.

View rescribet's full-sized avatar

Thom rescribet

View GitHub Profile
@rescribet
rescribet / base.rb
Last active September 17, 2016 06:06
A Turbolinks 5 drop-in for when permanent partials can't be lazy loaded (no-script requirement).
# A turbolinks 5 drop-in for when permanent partials can't be lazy loaded (no-script requirement).
#
# Whenever a static partial is really heavy, it is undesirable to render it on every/many request(s), so this render drop-in only renders the partial's content if the `Turbolinks-Referrer` header is *not* present.
#
# Usage:
# ```ruby
# render partial: 'navbar', permanent: true
# # => <div id="turbolinks_navbar" data-turbolinks-permanent="true">[Always rendered]</div> # Behaviour as described in the RailsConf '15 keynote, where HTML might be lazy loaded via JS
#
# render partial: 'navbar', permanent: 'navbar'
@rescribet
rescribet / react_ujs.js
Created July 20, 2015 23:38
Non-global react_ujs
/*globals React, Turbolinks*/
/* Modified react_ujs to prevent the components polluting global scope whenever possible.
* Since I use subdirs for my components, it also flattens the structure making
* _componentStore[className] possible.
* Creds for the react_ujs.js file to the people from react-rails (https://github.com/reactjs/react-rails)
*/
var path = require('path');
@rescribet
rescribet / gist:3cbe8a8487e9763a3da8
Last active August 29, 2015 14:23
Component prerender exception stacktraces

Stacktraces associated with this issue

In my application:

Encountered error "TypeError: Object function Symbol(description) {
      var value = new SymbolValue(description);
      if (!(this instanceof Symbol))
        return value;
 throw new TypeError('Symbol cannot be new\'ed');
Encountered error "TypeError: Object function Symbol(description) {
var value = new SymbolValue(description);
if (!(this instanceof Symbol))
return value;
throw new TypeError('Symbol cannot be new\'ed');
} has no method 'for'" when prerendering ActiveToggle with {<<...props hash here...>>}
var value = new SymbolValue(description);
if (!(this instanceof Symbol))
return value;
throw new TypeError('Symbol cannot be new\'ed');