Comments (5)
This behaviour is intended (see fce8bcb). I've removed the example from the wiki.
from liquid.
I don't really get why that change was made?
String multiplication is valid in Ruby: http://www.ruby-doc.org/core/classes/String.html#M001126
And I don't see why casting to a number will help you out?
from liquid.
The arithmetic filters were always intended primarily for numbers. I originally implemented them to accomodate strings as well, because I figured "what the heck, ruby provides it for free." The problem is that there's no other way of casting strings to numbers in liquid, and it meant that when you're using e.g. the value of an input field or the result of a {%capture%} tag as the filter argument, there was no way to do actual arithmetic with it.
from liquid.
Ok, understood.
But can I make an suggestion?
{{ 'foo111' | times:4 }}
#=> 'foo111foo111foo111foo111'
{{ 'foo111' | to_number | times:4 }}
#=> '444'
It's no real problem to me (and I'm no contributor to liquid), but I was just wondering...
from liquid.
Yeah, that was the other alternative that we considered, but ultimately we decided it was more important to make the common case easy than to accomodate the edge case with the same interface. (And as you say, the edge case is still possible with a loop).
One of the nice things about liquid is how extensible it is, so if you want to make your own filters for string manipulation to use in your project, it's easy to do that.
from liquid.
Related Issues (20)
- Possible to get full object & variable name with `strict_variables: true`?
- video_tag fully disable poster HOT 2
- Expose Liquid::Condition in public API
- alt attribute not set for media.preview_image with image_tag filter HOT 1
- Running rake example throws error
- Liquid rendering is unexpectedly changing the "context" attribute on non-Drop classes
- Liquid shopify skórki
- Add WISMOlabs to "Who uses Liquid?" wiki section
- App Block Missing Data On Theme Previews When Proceeded by a Hidden Section Containing an @app Block
- Sort orders by 'created_at' in paginate?
- Regarding deprecation of the total_discount
- Add limit to split filter, like split method in Ruby
- Liquid - Product Description Null Check Not Working
- Should strip_newlines also 'strip' LSEP ?
- Case statement evaluation renders multiple when conditions if a value is repeated
- String to Object? HOT 1
- ع
- Can't get key/value from hash HOT 6
- Allow overriding blank? method in drops HOT 1
- image_tag filter, incorrect width and height attribute values for SVG
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liquid.