Skip to content

Instantly share code, notes, and snippets.

@tadatuta
tadatuta / BEM-XJST.md
Last active December 25, 2015 17:49
BEM-XJST синтаксис

BEM-XJST

Это БЭМ-ориентированные хелперы над стандартным XJST-синтаксисом. Сюда входит:

  • синтаксический сахар для подпредикатов про БЭМ предметную область
  • возможность писать вложенные шаблоны
  • синтаксический сахар для apply по какой-то mode (apply(this._mode = 'bla'))
  • ключевое слово applyCtx (синтаксический сахар для applyNext(this.ctx = { some: 'new' }))
Подпредикаты про БЭМ
#!/bin/bash
if [ -z "${SAUCE_USERNAME}" ] || [ -z "${SAUCE_ACCESS_KEY}" ]; then
echo "This script can't run without your Sauce credentials"
echo "Please set SAUCE_USERNAME and SAUCE_ACCESS_KEY env variables"
echo "export SAUCE_USERNAME=ur-username"
echo "export SAUCE_ACCESS_KEY=ur-access-key"
exit 1
fi
SAUCE_TMP_DIR="$(mktemp -d -t sc.XXXX)"
@tadatuta
tadatuta / comments2iframe.js
Created November 30, 2014 00:57
Replace comments with iframes in enb-bem-docs results
(function(d) {
var body = d.body,
content = body.childNodes,
length = content.length;
function replaceComment(node) {
if(node.nodeType != 8) return;
var src = 'http://localhost:8080/' + node.data.replace(' bem-example: ', '').replace(' ', ''),
@tadatuta
tadatuta / html.js
Created December 6, 2014 20:51
bem-tools: php to html tech
var BEM = require('bem'),
Q = BEM.require('q'),
VM = require('vm'),
SPAWN = require('child_process').spawn;
function strEscape(s) {
return s.replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}
exports.API_VER = 2;
@tadatuta
tadatuta / make.js
Created December 10, 2014 22:03
enb conf for bemtree
@@ -15,7 +15,7 @@ var techs = {
prependYm: require('enb-modules/techs/prepend-modules'),
// bemtree
- // bemtree: require('enb-bemxjst/techs/bemtree-old'),
+ bemtree: require('enb-bemxjst/techs/bemtree-old'),
// bemhtml
bemhtml: require('enb-bemxjst/techs/bemhtml-old'),
@@ -40,8 +40,7 @@ module.exports = function(config) {
@tadatuta
tadatuta / bemhtml.js
Created November 10, 2015 15:59
bem-xjst@4 basic templates
/// -------------------------------------
/// --------- BEM-XJST Runtime Start ----
/// -------------------------------------
var BEMHTML = function(module, exports) {
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bemhtml = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
module.e
module.exports = {
block: 'page',
title: 'Title of the page',
favicon: '/favicon.ico',
head: [
{ elem: 'meta', attrs: { name: 'description', content: '' }},
{ elem: 'css', url: 'index.min.css' }
],
scripts: [{ elem: 'js', url: 'index.min.js' }],
content: [
module.exports = {
block: 'page',
title: 'Title of the page',
favicon: '/favicon.ico',
head: [
{ elem: 'meta', attrs: { name: 'description', content: '' }},
{ elem: 'css', url: 'index.min.css' }
],
scripts: [{ elem: 'js', url: 'index.min.js' }],
content: [
module.exports = {
block : 'page',
title : 'Title of the page',
favicon : '/favicon.ico',
head : [
{ elem : 'meta', attrs : { name : 'description', content : '' } },
{ elem : 'meta', attrs : { name : 'viewport', content : 'width=device-width, initial-scale=1' } },
{ elem : 'css', url : 'index.min.css' }
],
scripts: [{ elem : 'js', url : 'index.min.js' }],