Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for nunjucks in 11ty sites #116

Open
silveltman opened this issue Jun 27, 2022 · 2 comments
Open

Support for nunjucks in 11ty sites #116

silveltman opened this issue Jun 27, 2022 · 2 comments

Comments

@silveltman
Copy link

silveltman commented Jun 27, 2022

I would love to see support for nunjucks. It allows for more freedom in conditional classes, especially with things like tailwind.

Example

passing arguments to the component like size, color etc. Then in in nunjucks we can something like the following:

<div class="c-animals {{ 'bg-blue' if color == blue }}">...</div>

this is a lot cleaner then it would be in liquid.

Also things like this:
{% set bg-color= ('bg-blue' if color === 'blue' else 'bg-red') %}

@silveltman
Copy link
Author

silveltman commented Jun 27, 2022

I ended up using this, which is fine but still a little messy:

component file:

{% if blue %}
    {% assign bg = 'bg-blue' %}
    {% assign border = 'border-blue' %}
    {% assign text = 'text-white' %}
{% else %}
    {% assign bg = 'bg-yellow' %}
    {% assign border = 'border-yellow' %}
    {% assign text = 'text-black' %}
{% endif %}

<a href="{{ url }}" class="relative inline-flex items-center justify-center transition-all border-2 rounded-full {{ border }} group focus:{{ bg }}">
    <div class="absolute transition-all rounded-full {{ bg }} inset-2 group-hover:inset-1"></div>
    <span class="relative p-6 text-center {{ text }} material-icons aspect-1">
        {{ icon }}
    </span>
</a>

template file:
{% bookshop 'btn/icon' icon: 'open_in_new'%}

@bglw
Copy link
Contributor

bglw commented Jun 28, 2022

Hi Sil 👋

This is definitely something I'm looking to add support for, but I can't promise any timeline around it. Bookshop has pretty tight integration with the template contents, so I'll need to find a good chunk of time to work through this. Hopefully later this year :)

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

No branches or pull requests

2 participants