Giter VIP home page Giter VIP logo

Comments (9)

basbossink avatar basbossink commented on August 20, 2024

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.

phoet avatar phoet commented on August 20, 2024

@dcramer could you elaborate on that? give an example of what this should do exacltly?

from liquid.

nickpearson avatar nickpearson commented on August 20, 2024

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.

fw42 avatar fw42 commented on August 20, 2024

That sounds useful. Let me check if we already have something like this in Shopify. If not, you can PR.

from liquid.

fw42 avatar fw42 commented on August 20, 2024

Ok go ahead Nick, open a pull request, we would be happy to merge this.

from liquid.

fw42 avatar fw42 commented on August 20, 2024

Still interested in implementing this, @nickpearson?

from liquid.

nickpearson avatar nickpearson commented on August 20, 2024

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.

phoet avatar phoet commented on August 20, 2024

@nickpearson i think we can close this then?

from liquid.

nickpearson avatar nickpearson commented on August 20, 2024

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)

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.