salesforce-ux / theo

Theo is a an abstraction for transforming and formatting Design Tokens

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with accessing meta values?

bradryanbice opened this issue · comments

I have this YAML (portion)

props:
  # Spacing & Padding
  SDS_ACCORDION_CONTENT_PADDING:
    value: '{!SIZE_MEDIUM}'
    meta:
      css: 'padding'
  SDS_ACCORDION_HEADER_PADDING:
    value: '0 {!SIZE_MEDIUM}'
    meta:
      css: 'padding'
      modifier: 'header'

And I'm creating a custom format using this:

theo.registerFormat('sdsw.json', `
// Source: {{stem meta.file}}
{
    "props": {
        {{#each props as |prop|}}
        "{{prop.name}}": {
            "value": "{{prop.value}}",
            "meta": {
                "css": "{{prop.meta.css}}",
                "modifier": "{{prop.meta.modifier}}"
            }
        },
        {{/each}}
    }
}
`)

Which is returning empty values for the meta (name and value are returning just fine. Is this something I'm doing wrong?

You need to specify includeMeta: true in the transform options. Looks like the docs need to be updated. To be honest, this was a poorly conceived feature several versions ago and should probably be deprecated at some point. I specifically remove the meta key, but you can actually include any other top level keys in a prop and they will be passed through.

@aputinski Thank you, that transform option setting worked. I was pulling what was left of my hair out on that one.