Skip to content

Instantly share code, notes, and snippets.

View janfoeh's full-sized avatar

Jan-Christian Föh janfoeh

  • programmanstalt
  • Hamburg
View GitHub Profile
@janfoeh
janfoeh / pdf_renderer.rb
Created April 12, 2015 20:51
Rails 4.2 WickedPDF renderer class
# see https://github.com/rails/rails/issues/14125#issuecomment-44547905
# for clues about the Rails 4.1 specific changes
class PdfRenderer < AbstractController::Base
include ActionController::Helpers
include AbstractController::Rendering
include ActionView::Layouts
append_view_path "#{Rails.root}/app/views"
@janfoeh
janfoeh / binding-childvm.js
Last active December 31, 2015 01:29
Nested viewmodels for Knockout
ko.bindingHandlers.childVm = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
var vmName = ko.unwrap(valueAccessor()),
childVm;
childVm = ko.utils.arrayFirst(viewModel._childVms(), function(item) {
return item._viewmodelName() === vmName;
});
// 'with' returns {controlsDescendants: true}, so we have to pass it up - otherwise,