Skip to content

How to create component "presets"? #136

Closed Answered by wrabit
iamalexpayne asked this question in Q&A
Discussion options

You must be logged in to vote

@iamalexpayne

  1. I am not sure if django natively supports multi-line tags as you have laid out with your with
  2. I don't think this should work either style=styles=(common_styles|add:primary_styles if style == 'primary' else common_styles|add:secondary_styles) are you sure this is working code even without cotton?
  3. You can reach for <c-vars />, and something like this may help you:

This does rely on you adding an item getter templatetag to get an item from a dict by its key.

So putting this in a templatetag file and loading it:

@register.filter
def get_item(dictionary, key):
    return dictionary.get(key)

(an upcoming cotton version will have this baked in)

And then you can do:

<!-- button.ht…

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@iamalexpayne
Comment options

@confuzeus
Comment options

@fertek
Comment options

@wrabit
Comment options

Answer selected by wrabit
Comment options

You must be logged in to vote
4 replies
@wrabit
Comment options

@iamalexpayne
Comment options

@wrabit
Comment options

@iamalexpayne
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants