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

Additional guard methods (match, regex) #2638

Closed
titpetric opened this issue Jul 17, 2015 · 2 comments
Closed

Additional guard methods (match, regex) #2638

titpetric opened this issue Jul 17, 2015 · 2 comments

Comments

@titpetric
Copy link

I'd like to implement additional guards, which could be used for matching against the value as a string literal. For example:

.background(@value) when (ismatch(@value, "\.svg$")) {
    background-size: 64px;
}
.background(@value) when (ismatch(@value, "@2x")) {
    background-size: floor(image-width(@value) / 2);
}

Seems the function is quite easy to add to Less, I found the code for other guards right away. What are your thoughts, does something like this have a chance to be included in the master branch? Any comments regarding implementation details?

@seven-phases-max
Copy link
Member

Implement this as a plugin. While it's not a big deal to feed the language with thousands of functions (yeah, they are cheap to implement) it's not always a good idea to make this just because it's possible.
It's all about use-cases, if there's enough interest it is always possible to move functions from a plugin to the core (after all it already has string replace function, so having corresponding find would not sound too artificial).

@stale
Copy link

stale bot commented Nov 14, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants