I'm using Jammit to package assets up for a Rails application and I have a few asset files that I'd like to be included in each of a few groups. For example, I'd like Sammy and its plugins to be in both my mobile
and screen
JS packages.
I've tried this:
sammy: &SAMMY - public/javascripts/vendor/sammy.js - public/javascripts/vendor/sammy*.js mobile: <<: *SAMMY - public/javascripts/something_else.js
and this:
mobile: - *SAMMY
but both put the Sammy JS files in a nested Array, which Jammit can't understand. Is there a syntax for including the elements of an Array directly in another Array?
NB: I realize that in this case there are only two elements in the SAMMY
Array, so it wouldn't be too bad to give each an alias and reference both in each package. That's fine for this case, but quickly gets unmaintainable when there are five or ten elements that have a specific load order.
YAML Anchors and Alias You can place Anchors ( & ) on an entity to mark a multi-line section. You can then use an Alias ( * ) call that anchor later in the document to reference that section. Anchors and Aliases are very helpful for larger projects as they cut visual clutter caused by extra lines.
The block sequence style of YAML uses hyphens or dashes to ( - ) to represent arrays. A hyphen ( - ) followed by white space ( ) represents an element of an array. When you enter the dashes, you need to ensure that all items are at the same indentation level.
YAML anchors are a feature which let you identify an item and then reference it elsewhere in your file. Anchors are created using the & sign. The sign is followed by an alias name. You can use this alias later to reference the value following the anchor.
The native data structure in YAML includes simple representations such as nodes. It is also called as Representation Node Graph. It includes mapping, sequence and scalar quantities which is being serialized to create a serialization tree. With serialization the objects are converted with stream of bytes.
Closest solution I know of is this one:
sammy: - &SAMMY1 public/javascripts/vendor/sammy.js - &SAMMY2 public/javascripts/vendor/sammy*.js mobile: - *SAMMY1 - *SAMMY2 - public/javascripts/something_else.js
Alternatively, as already suggested, flatten the nested lists in a code snippet.
Note: according to yaml-online-parser, your first suggestion is not a valid use of << (used to merge keys from two dictionaries. The anchor then has to point to another dictionary I believe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With