Skip to content

Instantly share code, notes, and snippets.

rjgotten

  • NetMatch
Block or report user

Report or block rjgotten

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View can-stache-loader.js
var loaderUtils = require("loader-utils");
var parse = require("can-stache-ast").parse;
function makeRenderer(imports, intermediate, filename) {
intermediate = JSON.stringify(intermediate);
filename = JSON.stringify(filename);
imports = imports.map(function(imported) {
imported = JSON.stringify(imported);
return `${imported} : Promise.resolve(require(${imported}))`
@rjgotten
rjgotten / import.js
Created Aug 23, 2016
More complete AMD loader support for can-util/js/import/import
View import.js
var isFunction = require('../is-function/is-function');
var global = require("../global/global")();
/**
* @module {function} can-util/js/import/import import
* @parent can-util/js
* @signature `importModule(moduleName, parentName)`
*
* ```js
* var importModule = require("can-util/js/import/import");
@rjgotten
rjgotten / literal.js
Last active Aug 29, 2015
Emit literal content with Less plugin functions and detached rulesets
View literal.js
function Literal( text ) {
this.text = text;
}
Literal.prototype = new tree.Node();
Literal.prototype.constructor = Literal;
Literal.prototype.type = "Literal";
Literal.prototype.accept = function ( visitor ) {};
Literal.prototype.eval = function ( context ) {
return new Literal( this.text );
View each.less
.each(@list, @ruleset) {
@plugin "plugins/lambda";
@length : length(@list);
._iterate(1);
._iterate(@index) when (@index =< @length) {
@item : extract(@list, @index);
@lambda : lambda(@item, @index, item index, @ruleset);
@lambda();
@rjgotten
rjgotten / foreach.less
Last active Aug 29, 2015
Using detached rulesets as lambda delegates without scoping issues; in reply to: https://gist.github.com/seven-phases-max/5280eacdf3d591f35163
View foreach.less
// @mixin
// Loops over all items in the specified list and for each item executes
// a special `.\\` mixin declared by the specified ruleset. The ruleset
// and mixin combination is used to emulate a lambda function delegate.
// @param {List} list
// The list over which to loop.
// @param {Ruleset} lambda
// A ruleset that may define the `.\\` mixin that is used to process the
// individual list items. The mixin should correspond to the
// following signature:
@rjgotten
rjgotten / can.compute.when.js
Last active Aug 29, 2015
Wrapping can.Deferred as a can.compute
View can.compute.when.js
can.compute.when = function( computer ) {
var
promise,
combined,
result;
// Ensure that we always get back a then-able promise from `computer`,
// and that it is infact a `can.compute` and not a regular function.
promise = can.compute( function() { return can.when( computer()) });
You can’t perform that action at this time.