Git Product home page Git Product logo

Comments (6)

nei avatar nei commented on May 27, 2024 2

This configuration would also be appreciated on SF bridge.

Something like this or anything that allow us to addRule for simple cases.

cocur_slugify:
    separator: "_"
    rulesets:
        - default
        - [".",""]

from slugify.

florianeckerstorfer avatar florianeckerstorfer commented on May 27, 2024 1

@nei This would be the correct approach for solving this.

When we are talking about just the Twig integration because it could be part of the SF bridge, but it could also mean just straight-up Twig.

Alternatively for Twig we could add a slugfiy_add_rule tag to allow editing rules. I would prefer not to change the call for slugify because I think it should match the PHP methods signature.

from slugify.

florianeckerstorfer avatar florianeckerstorfer commented on May 27, 2024

You should call addRules() on the Slugify object before you inject it to the Cocur\Slugify\Bridge\Twig\SlugifyExtension constructor.

from slugify.

harsain avatar harsain commented on May 27, 2024

That's correct. but will only work if we know the rule to be added.
instead the scenario i am talking about is when the rule is not known and will be passed from the twig template.

So something like:

{{name | slugify(null, {'&': 'and'}) }}

As, you can see here the php level code doesn't know the rule but will be passed from template

Regards,

from slugify.

harsain avatar harsain commented on May 27, 2024

@florianeckerstorfer adding a tag would be a better option ...

I was more talking about the scenario where the Frontend guys don't know anything about the backend and have no knowledge about the configurations, in that scenario they can just pass and new rules directly from the twig template and no change in the backend will be required

from slugify.

Pazns avatar Pazns commented on May 27, 2024

@harsain Putting this kind of logic inside your template seems like a good idea to get unmanageable code.

from slugify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.