Comments (9)
I have to agree with this one wholehartedly. An addition it would be nice if {% highlighting %} blocks would never be broken up as well.
from liquid.
@dcramer could you elaborate on that? give an example of what this should do exacltly?
from liquid.
I'm guessing the request was for a filter that truncates a string without causing problems with the resulting HTML. For example, truncating <a href="/home">Read more here</a>
at 15 characters would result in <a href="/ho...
(creating invalid HTML) rather than what was likely intended: <a href="/home">Read more he...
, where the visible text is 15 characters (and the length of the HTML code is much longer).
I wrote a filter for my own app that truncates an HTML string, leaving the HTML intact and closing any tags that were opened before the truncation and closed after it (where the closing tags were cut off). Using my example from above, my filter would return <a href="/home">Read more he...</a>
.
There's a fair amount of code to accomplish this, but if it's something you guys would like to see added to Liquid itself, I'd be happy to submit a pull request with the code. Otherwise, if this functionality is outside Liquid's scope, I can just post a code sample here.
from liquid.
That sounds useful. Let me check if we already have something like this in Shopify. If not, you can PR.
from liquid.
Ok go ahead Nick, open a pull request, we would be happy to merge this.
from liquid.
Still interested in implementing this, @nickpearson?
from liquid.
Yes, apologies being late on this. I've implemented it and am refining the code a bit before submitting a PR. I guess it can't hurt to submit what I've got for critique. I'll see if I can get that done this week. Thanks for following up.
from liquid.
@nickpearson i think we can close this then?
from liquid.
Yes, let's close it. I haven't had the time to address all the issues @fw42 pointed out in my PR. If I get a chance to improve my code I'll submit another one.
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.