Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Andrey Popp andreypopp

🏠
Working from home
Block or report user

Report or block andreypopp

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 asyncawait.sjs
macro __rejectAwait {
case { _ $body ... } => {
letstx $await = [makeIdent('await', #{$body ...}[0])];
return #{
macro $await {
case { $name:ident $e:expr } => {
throwSyntaxError('await', 'cannot use await keyword outside of async function', #{$name});
}
}
$body ...
@andreypopp
andreypopp / di.sjs
Created Feb 3, 2014
Dependency injection DSL for JavaScript
View di.sjs
macro emitQuery {
case { _ $id:ident } => {
letstx $name = [makeValue(#{$id}[0].token.value, #{$id})];
letstx $registry = [makeIdent('registry', #{$id})];
return #{ var $id = $registry.query($name) }
}
}
macro inject {
case { _ $id:ident (,) ... { $body ...} } => {
View with-macros.sjs
var theme = require('my-theme');
module.exports = style {
background-color: {theme.bgColor};
}
View Component.css
@import "./theme" as theme
.Component {
.Child {
width: var(theme.width);
}
}
View gist:8865144
function condition(props) {
return props.if ? Array.prototype.slice.call(arguments, 1) : [];
}
var Component = React.createClass({
render: function() {
return (
<div>
<condition if={this.state.show}>
True!
@andreypopp
andreypopp / macroFilter.sjs
Last active Aug 29, 2015
Array.prototype.filter-like method call expanded into an efficient loop
View macroFilter.sjs
macro replace {
case { _ $a:expr $b:expr { $first $rest ... } } => {
if ($a.token.value === $first.token.value) {
return #{ $b replace $a $b $rest ... }
} else {
return #{ $first replace $a $b { $rest ... } }
}
}
case { _ $a:expr $b:expr { } } => {
return [];
View assets.js
function Stylesheets() {
var registry = requireAssets.currentRegistry();
var stylesheets = [];
for (var url in registry.urlToFilename)
if (/\.css$/.exec(url))
stylesheets.push(<link rel="stylesheet" key={url} href={url} />);
return stylesheets;
}
var App = React.createClass({
View page.rd
---
title: Some new title
...
# some new stuff
And now some text is here
Another test
View output-0.8.0.js
/**
* @jsx React.DOM
*/
var jsx = (
React.DOM.div(null,
" Hello, " ,
React.DOM.a(null, "world!")
)
);
View plugins.js
var React = require('react');
var Router = require('react-router-component');
var Link = Router.Link;
var Locations = Router.Locations;
var Location = Router.Location;
var plugins = [
{title: 'Reports', path: '/reports', handler: ReportHandler},
...
];
You can’t perform that action at this time.