aurelia-bem
Advanced tools
Comparing version 0.2.0 to 0.3.0
export declare function bemClassGenerator(block?: string, element?: string, modifier?: string | string[]): any[]; | ||
export declare function bem(block?: string, element?: string, modifier?: string | string[]): string; | ||
export declare class BemBinder { | ||
beforeBind(view: any): void; | ||
} |
@@ -13,15 +13,17 @@ "use strict"; | ||
if (block && !element) { | ||
result.push(block); | ||
result.push(checkForValidName(block)); | ||
} | ||
if (element) { | ||
checkForValidName(element, !block); | ||
result.push(block ? block + "__" + element : element); | ||
} | ||
function pushModifier(m) { | ||
checkForValidName(m); | ||
if (element) { | ||
result.push(block | ||
result.push((block | ||
? block + "__" + element + "--" + m | ||
: element + "--" + m); | ||
: element + "--" + m)); | ||
} | ||
else { | ||
result.push(block + "--" + m); | ||
result.push((block + "--" + m)); | ||
} | ||
@@ -40,5 +42,17 @@ } | ||
exports.bemClassGenerator = bemClassGenerator; | ||
function checkForValidName(name, noBlock) { | ||
if (noBlock === void 0) { noBlock = false; } | ||
var tester = new RegExp("[-" + (noBlock ? "" : "|_") + "]{2,}"); | ||
if (name.match(tester) || name.match(/_{2,}.*_{2,}/)) { | ||
console.error("Usage of invalid separators in given name " + name); | ||
} | ||
if (noBlock && !name.includes("__")) { | ||
console.error("Given name " + name + " includes no __ and no block provided"); | ||
} | ||
return name; | ||
} | ||
function bem(block, element, modifier) { | ||
return bemClassGenerator(block, element, modifier).join(" "); | ||
} | ||
exports.bem = bem; | ||
var BemBinder = (function () { | ||
@@ -45,0 +59,0 @@ function BemBinder() { |
import { FrameworkConfiguration } from 'aurelia-framework'; | ||
export declare function configure(config: FrameworkConfiguration): void; | ||
export * from "./bem"; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -10,3 +13,4 @@ var bem_1 = require("./bem"); | ||
exports.configure = configure; | ||
__export(require("./bem")); | ||
//# sourceMappingURL=index.js.map |
export declare function bemClassGenerator(block?: string, element?: string, modifier?: string | string[]): any[]; | ||
export declare function bem(block?: string, element?: string, modifier?: string | string[]): string; | ||
export declare class BemBinder { | ||
beforeBind(view: any): void; | ||
} |
@@ -11,15 +11,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
if (block && !element) { | ||
result.push(block); | ||
result.push(checkForValidName(block)); | ||
} | ||
if (element) { | ||
checkForValidName(element, !block); | ||
result.push(block ? block + "__" + element : element); | ||
} | ||
function pushModifier(m) { | ||
checkForValidName(m); | ||
if (element) { | ||
result.push(block | ||
result.push((block | ||
? block + "__" + element + "--" + m | ||
: element + "--" + m); | ||
: element + "--" + m)); | ||
} | ||
else { | ||
result.push(block + "--" + m); | ||
result.push((block + "--" + m)); | ||
} | ||
@@ -37,3 +39,14 @@ } | ||
} | ||
function bem(block, element, modifier) { | ||
function checkForValidName(name, noBlock) { | ||
if (noBlock === void 0) { noBlock = false; } | ||
var tester = new RegExp("[-" + (noBlock ? "" : "|_") + "]{2,}"); | ||
if (name.match(tester) || name.match(/_{2,}.*_{2,}/)) { | ||
console.error("Usage of invalid separators in given name " + name); | ||
} | ||
if (noBlock && !name.includes("__")) { | ||
console.error("Given name " + name + " includes no __ and no block provided"); | ||
} | ||
return name; | ||
} | ||
export function bem(block, element, modifier) { | ||
return bemClassGenerator(block, element, modifier).join(" "); | ||
@@ -40,0 +53,0 @@ } |
import { FrameworkConfiguration } from 'aurelia-framework'; | ||
export declare function configure(config: FrameworkConfiguration): void; | ||
export * from "./bem"; |
@@ -7,3 +7,4 @@ import { BemBinder } from './bem'; | ||
} | ||
export * from "./bem"; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "aurelia-bem", | ||
"description": "An Aurelia plugin project.", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -1,2 +0,2 @@ | ||
import {viewEngineHooks} from 'aurelia-templating'; | ||
import { viewEngineHooks } from 'aurelia-templating'; | ||
@@ -11,6 +11,7 @@ export function bemClassGenerator( | ||
if (block && !element) { | ||
result.push(block); | ||
result.push(checkForValidName(block)); | ||
} | ||
if (element) { | ||
checkForValidName(element, !block); | ||
result.push(block ? `${block}__${element}` : element); | ||
@@ -20,10 +21,11 @@ } | ||
function pushModifier(m) { | ||
checkForValidName(m); | ||
if (element) { | ||
result.push( | ||
result.push(( | ||
block | ||
? `${block}__${element}--${m}` | ||
: `${element}--${m}` | ||
); | ||
)); | ||
} else { | ||
result.push(`${block}--${m}`); | ||
result.push((`${block}--${m}`)); | ||
} | ||
@@ -43,3 +45,18 @@ } | ||
function bem( | ||
function checkForValidName(name: string, noBlock = false) { | ||
const tester = new RegExp(`[-${noBlock ? "" : "|_"}]{2,}`); | ||
if (name.match(tester) || name.match(/_{2,}.*_{2,}/)) { | ||
console.error(`Usage of invalid separators in given name ${name}`); | ||
} | ||
if (noBlock && !name.includes("__")) { | ||
console.error(`Given name ${name} includes no __ and no block provided`); | ||
} | ||
return name; | ||
} | ||
export function bem( | ||
block?: string, | ||
@@ -46,0 +63,0 @@ element?: string, |
@@ -9,1 +9,3 @@ import { FrameworkConfiguration } from 'aurelia-framework'; | ||
} | ||
export * from "./bem"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26718
276