- can not be conditional (
if (someVar) { import 'path' }
- can not be evaluated (
import 'path-' + someVar
)
Feature | Node.js | Browserify | ES Import |
---|---|---|---|
Conditional require | yes | yes | no |
Dynamic path | yes | no | no |
import text from 'text_en.json?i18n'; | |
export default [ | |
{ | |
path: `/:country(${text.country})/:state/:city/${text.profile}/:category/:name-:bbbId-:businessId`, | |
id: 'businessprofile', | |
component: BusinessProfile, | |
}, | |
{ | |
path: `/:country(${text.country})(/:state)(/:city)/${text.categories}(/:letter)`, |
Typekit.load({async:true,active:function() { | |
Array.prototype.some.call(document.head.children, function (node) { | |
if (node.tagName === 'STYLE' && node.innerHTML.indexOf('typekit.net') > -1 && node.innerHTML.indexOf('@font-face') > -1) { | |
window.localStorage.setItem('ts.fontFace', node.innerHTML); | |
return true; | |
} | |
return false; | |
}); | |
}}); |
<?php | |
namespace vendorName\pluginName\controllers; | |
use Craft; | |
use craft\helpers\Assets; | |
use craft\elements\Asset; | |
use craft\elements\Entry; | |
use craft\web\Controller; | |
class ExampleController extends Controller { |
import React, { Component, createElement } from 'react'; | |
import items from './items-service.js'; | |
function handleRemoveItem(name) { | |
return () => { | |
items.remove(name); | |
}; | |
} | |
export default props => |
//////////////////////////// | |
// Slope Calc Mixin // | |
//////////////////////////// | |
// | |
// Usage: | |
// | |
// .my-widget { | |
// @include slope-calc(padding, 20px 320px, 60px 1440px, 60px 1441px); | |
// } | |
// |
// # Anatomy of an ES2015 Javascript Module | |
// *for older modules, see:* [ES5 Javascript Module](https://gist.github.com/btpoe/de6fd193b7dc822ef3a6) | |
// ## Module Defaults | |
// Important to note: These are shared across all instances and will only be calculated once. | |
// Export the defaults so that other modules can read them if necessary. | |
export const DEFAULTS = { | |
param: 'default_value' | |
}; |
// takes a em value and returns the value 1 less pixel | |
@function rev($unit) { | |
@return $unit - (1/16); | |
} | |
// ****************** // | |
// * Breakpoints * // | |
// ****************** // |
// # Anatomy of a Javascript Module | |
// *for newer modules, see:* [ES2015 Javascript Module](https://gist.github.com/btpoe/55470d6b4b8bfca56e8f) | |
// ## The Constructor | |
// First, define a constructor function. The goal is to keep this function as lightweight as | |
// possible. For the first argument, we're going to receive an HTMLElement. This element is | |
// critical because it is essentially the key to this module instance. The second argument is all | |
// of the developer defined options for this particular instance. For any option used, we should | |
// declare a default (seen below) to prevent the module from breaking if certain options are not | |
// provided. |