Giter Club home page Giter Club logo

Comments (4)

senny avatar senny commented on July 20, 2024

@stadelmanma if we would break backwards compatibility we will need a very good reason to do so. It would mean that upgrading potentially means that you need to update all your templates.

To provide some context, would you mind sharing some expressions that this enables that are not possible now? Ideally this would be real-world use-cases and not constructed scenarios.

One more thing, in the beginning I deliberately kept the expression complexity low. Editing templates is not fun, you should be editing code. So instead of defining complex expressions in the template Sablons take would be to define a wrapping object with a method that does what you need. You can then easily change that method without needing to update any templates. I think in terms of maintenance this is a huge benefit.

from sablon.

stadelmanma avatar stadelmanma commented on July 20, 2024

@senny don't worry I'm not sold on this idea either (hence the proposed 😉 ). It came to mind as a way to make our context manipulations more powerful so I decided to jot it down, and invite any feedback.

Permitting more complex expressions would be part of a second PR that refactors our conditional and loop statements into the natural ruby syntax. i.e. paragraph:if becomes if pragraph. We would also have the benefit of leveraging the entire ruby environment implicitly without needing to manually code equivalent "sablon expressions" such each and if. Maintaining backwards compatibility in the second part is easy by using the same regular expression patterns we already use to transform the "old" syntax into the new.

Originally I thought this could be implemented without breaking backwards compatibility. However, after some testing and research it doesn't seem like that is possible and I don't think there are enough benefits to warrant the change. Especially given the tedium involved in updating those word templates.

from sablon.

senny avatar senny commented on July 20, 2024

Thanks for explaining this further. Having a more "natural" syntax would be nice for sure. However, my other point stands, you don't want these expressions in the template to get complex. You want the complexity in your code. Ping me if you happen to do a spike to implement this. I'd be interested in seeing the internals. I vaguely remember that there were some issues with parsing to know if it's a block or not, I can imagine that parsing real Ruby would be tricky.

from sablon.

stadelmanma avatar stadelmanma commented on July 20, 2024

Closing this as it isn't something that I think fits well within the original intent of sablon, which was to keep templates simple because they are a real pain to debug.

Something I want to do eventually is refactor the logic used to handle merge fields and their corresponding operations to allow easier extension by the end user (a sort of plugin type of API maybe). Perhaps depending on the flexibility added by those changes this could be implemented separately as an extension gem instead of being part of the core components.

from sablon.

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.