Releases: CarbonPackages/Carbon.Eel
2.16.1
2.16.0
✨ New Eel helper
Carbon.String.getPropertyFromNodeLink(node, value, propertyName, fallback)
Get a property from a node link. Can be used to get the title from a page who is linked via the link editor.
Example:
Expression | Result |
---|---|
Carbon.String.getPropertyFromNodeLink(site, 'node://aaaa-bbbb-ccc') |
'Title from the linked page' |
Carbon.String.getPropertyFromNodeLink(site, 'node://aaaa-bbbb-ccc', null) |
null |
Carbon.String.getPropertyFromNodeLink(null, 'node://aaaa-bbbb-ccc') |
null |
Carbon.String.getPropertyFromNodeLink(site, 'some other value') |
null |
Carbon.String.getPropertyFromNodeLink(site, 'some other value', 'title', 'fallback value') |
'fallback value' |
node
(NodeInterface) The node, usallysite
value
(string) The value to processpropertyName
(string) The name of the property to getfallback
(mixed) The fallback value if nothing is found
Full Changelog: 2.15.2...2.16.0
2.15.2
Full Changelog: 2.15.1...2.15.2
2.15.1
Full Changelog: 2.15.0...2.15.1
2.15.0
2.14.0
Rename Carbon.String.merge
to Carbon.String.classNames
Render all arguments as classNames and apply conditions if needed.
Merge strings and arrays to a string with unique values, separated by an empty space.
All arguments of the eel helper are evaluated and the following rules are applied:
- falsy values: (
null
,''
,[]
,{}
) are not rendererd - array: all items that are scalar and truthy are rendered as classname
- object: keys that have a truthy values are rendered as classname
- scalar: is cast to string and rendered as class-name
Examples:
Expression | Result |
---|---|
Carbon.String.classNames('', 'one') |
'one' |
Carbon.String.classNames(['one two three'], ['one', 'four']) |
'one two three four' |
Carbon.String.classNames(null, false, [null], {one: false}) |
null |
Carbon.String.classNames('one two three', ['one', 'four']) |
'one two three four' |
Carbon.String.classNames('one', {two: true, three: false }) |
'one two' |
Return The merged string
Rename AlpineJS.xData
to AlpineJS.function
Generate a function call for AlpineJS. More info.
Supports nested arrays. In named arrays ({first:1,second:null}
) null
get filtered out, but in list
arrays ([1,null]
) and in plain values the will stay.
Examples:
Expression | Result |
---|---|
AlpineJS.function('slider', {effect: 'slide', spaceBetween: 12, loop: true, navigation: null}) |
'slider({effect:'slide',spaceBetween:12,loop:true})' |
AlpineJS.function('slider', 'one', 1, false, null, ['string', 2, null]) |
'slider('one',1,false,null,['string',2,null])' |
AlpineJS.function("vote", 4) |
'vote(4)' |
name
(string) The name for the function (e.gx-data
,x-on:click
, etc.)...arguments
(mixed) The options for the function
Return The string for the x-data function call
Full Changelog: 2.13.0...2.14.0
2.13.0
AlpineJS.magic(name, arg1, arg2, ..argN)
Generate a call for a magic function for AlpineJS..
Supports nested arrays. In named arrays ({first:1,second:null}
) null
get filtered out, but in list
arrays ([1,null]
) and in plain values the will stay.
Examples:
AlpineJS.magic('dispatch', 'notify') == '$dispatch('notify')'
AlpineJS.magic('$dispatch', 'notify', { message: 'Hello World!' }) == '$dispatch('notify',{message:'Hello World!'})'
AlpineJS.xData('dispatch', 'notify', { message: true, nested: {value: true} }) == '$dispatch('notify',{message:true,nested:{value:true}})'
name
(string) The name for the magic. If not prefixed with an$
, it will automatically prefixed....arguments
(mixed) The options for the function
Return The string for the magic function call
Full Changelog: 2.12.0...2.13.0
2.12.0
Carbon.String.replaceOnce(string, search, replace)
Helper to replace the first occurrence of a string.
Examples:
Expression | Result |
---|---|
Carbon.String.replaceOnce('Foo Bar Foo', 'Foo', 'X') |
'X Bar Foo' |
Carbon.String.replaceOnce('Foo Bar Foo', 'Foo ') |
'Bar Foo' |
string
(string) The string being searched and replaced onsearch
(string) The value being searched forprefix
(string, optional) The replacement value that replaces found search value
Returns the string with one occurrence replaced
Full Changelog: 2.11.0...2.12.0
2.11.0
Carbon.Number.pxToRem(value, fallback)
Convert a pixel value to rem
value
(numeric | string, required) The value to convertedfallback
(numeric | string, optional) Fallback value ifvalue
isfalse
ornull
Examples:
Expression | Result |
---|---|
Carbon.Number.pxToRem('') |
0 |
Carbon.Number.pxToRem('8px') |
0.5rem |
Carbon.Number.pxToRem(16) |
1rem |
Carbon.Number.pxToRem(0) |
0 |
Carbon.Number.pxToRem(false, 32) |
2rem |
Carbon.Number.pxToRem(null, '16px') |
2rem |
Returns a string with the converted value
Full Changelog: 2.10.0...2.11.0
2.10.0
✨ Add JavaScript and CSS minifier
Carbon.String.minifyJS(javascript)
Minifies JavaScript so that it can be delivered to the client quicker.
javascript
(string, required) The JavaScript to minify
Return The minified JavaScript
Carbon.String.minifyCSS(javascript)
Minifies CSS so that it can be delivered to the client quicker.
css
(string, required) The CSS to minify
Return The minified CSS
Full Changelog: 2.9.0...2.10.0