Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Pattern-specific listItems #74

Closed
tylersticka opened this issue Dec 13, 2013 · 4 comments
Closed

Pattern-specific listItems #74

tylersticka opened this issue Dec 13, 2013 · 4 comments
Assignees

Comments

@tylersticka
Copy link

Two features I love in Pattern Lab:

  • The ability to extend _data.json with pattern-specific data.
  • The listItems helper.

It would be so darn cool if you could extend _listitems.json similarly.

Example: I want a specific pattern to have a list of items with a human time difference. Ideally, it'd be neat if I could somehow specify a pattern specific _listitems.json file like this:

{
  "1": {
    "timeago": {
      "amount": "4",
      "unit": {
        "long": "years",
        "medium": "yrs",
        "short": "y"
      }
    }
  },
  "2": {
    "timeago": {
      "amount": "7",
      "unit": {
        "long": "minutes",
        "medium": "min",
        "short": "m"
      }
    }
  }
}

(There's also a chance I'm just treating _listitems.json as sacred when it really isn't.)

@dmolsen
Copy link
Member

dmolsen commented Dec 14, 2013

@tylersticka -

While _listems.json isn't sacred that feature should be extendable in the same way as _data.json. Again, editing that part of PL so it's good timing :)

@dmolsen dmolsen mentioned this issue Dec 14, 2013
31 tasks
@ghost ghost assigned dmolsen Dec 14, 2013
@dmolsen
Copy link
Member

dmolsen commented Jan 8, 2014

@tylersticka -

This feature has landed in dev. I'd like to test it some more but it seems to work. Real docs will make their way to the pattern lab site once we get ready to push the new release. For now a simple example. To override the listItems to be used on pages-article do the following:

  1. Create 04-pages/02-article.listitems.json
  2. In 02-article.listitems.json add your elements with the same numbering as _data/_listitems.json.

If the items share the same keys data will be replaced. Otherwise it will be appended. Play with it and you'll quickly see how it works.

@dmolsen dmolsen closed this as completed Jan 8, 2014
@tylersticka
Copy link
Author

@dmolsen This sounds great, can't wait to give it a shot. Thanks so much!

@karthi-siva
Copy link

how do we name listItems more then 20 ie: for 20: {{# listItems.twenty }}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants