-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added a - almost clean - include #{str_tmpl} feature :D #480
Conversation
Can it include-render to an Appender? What about the case where you'd like to include another .dt file? Does this force to use I'm thinking about creating events with std.events so that some html from multiple libraries can be added at runtime depending on an array of e.g. I'd want to build a templating library that has every possible position (left, top, right, bottom, etc.), where I can do div#top And where I can add some dub dependencies to the project like vibe-menu, vibe-search-module, and from it I could have the .dt files: top.menu.dt and top.search.dt, which are automatically compiled into the templating library. Of course, they would also have js.menu.dt and js.search.dt that adds any js to the head of the page in templates and so on. How would that sound? Naturally this is a rough example, the libraries would have configurations ( I chose Lua for my framework..) where you can decide which domains/routes should include the module or not and so on, but you can see the general idea and I feel you're not to far off from including multiple DT files with wildcards. |
the #{string} syntax is just for stringIncludes, that is the string has to be avilable at compile-time as it is included in before template compilation. |
I'm thinking of something around the lines of
Does this seem do-able to you? I don't know as much about diet templates but if you confirm maybe I can work on it, I need to try avoiding implementing this as manual delegate handlers with string-based & runtime callbacks. Maybe the only way would be to add a delegate call at the beginning of each diet template (compiled) call at runtime, where sub-projects' diet template engine can hook with the corresponding dependencies' updated diet template, and override the outdated diet template, with the newer one having populated the #{top.*} style includes. |
Do-able? Yes! |
I don't understand what you mean. This works
|
I agree that a static foreach would be awesome. In the meantime we'll have to do with recursion :/
This is an attempt at making a semi-dynamic array with enums, static foreach doesn't work :/ My thought is that compiled diet templates and their raw counterparts with the templated arguments could be sent to an enum with the ident being the dt filename and compiled by the main project with the #{top.} part filled in using __traits(compiles, mixin("ctRegex(top.)") ) with some sort of ctRegex for enum existence... |
please let's do futher discussions at either the rejectedsoftware or dlang forum |
sure |
Finished ... |
I guess it's now mergeble |
@s-ludwig is there any reason not to merge it ? |
Sorry, still catching up with a lot of github/forum stuff, it will take a little more time until I can make proper review/reply. One thing that would be good though would be if you could squash+rebase against the latest master, so that the history gets cleaned up. |
Will do. |
Ahm I did something wrong while rebaseing I guess |
It looks like just the pull request now points to your |
New one needs to be open. One of absolutely terrible GitHub misfeatures, you can edit pretty much anything in PR but the base branch. |
Hello,
I added a functions to vibe/templ/diet.d to inject a compile-time generated diet-template into an exsiting template
the code should be fairly obivous.
Could you review it ?
In return I'll add alot of documentation to vibe.d :D
rationals at
http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/10332/
update!
you can now say
enum hello = "h1 Hello World"
stringIncludeRender!("templ.dt",hello)
If the templ.dt looks like this
html
head
title Hello World
body
include #{hello}
you should see Hello World :D