Comments (4)
@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.
@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.
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.
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)
- Can i access a specific item in an array? HOT 2
- Dynamic Table Columns HOT 3
- Adding table to html creates corrupted file HOT 3
- template members get automatically stripped HOT 3
- image: "auto" property to keep aspect ratio HOT 2
- HTML Table got inserted without width HOT 1
- Conditionals: allow string comparism HOT 4
- Remove empty pages on the generated docx HOT 4
- Issue with inserting a Hyperlink via HTML content. HOT 2
- Table header: repeat on subsequent pages HOT 1
- Use mail merge fields in LibreOffice Writer HOT 1
- nested tables support? HOT 5
- Insert new mail merge fields using sablon HOT 2
- How to iterate over values of a hash? HOT 1
- Insert Templates into one another HOT 2
- Is it possible to specify the Word "Table Style" with an HTML <table>?
- Re-using content with images on multiple renders HOT 5
- p is not a valid child element of div HOT 4
- Injecting text-align: justify into docx file
- Unicode control characters in inputs may break generation of documents HOT 2
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 sablon.