-
Notifications
You must be signed in to change notification settings - Fork 62
added context to template engine #30
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
base: master
Are you sure you want to change the base?
Conversation
added copyright
started implementing django for-loop
added context
|
Thank you for this PR @tobias-loew . I suspect the project and other VS specific files are useful. Is there a way to move them to a subdirectory without causing problems? |
|
Sorry for that. I'll remove the VS stuff and some other junk and update the PR with my latest changes from this week. Just be patience for some days... |
updated django-development removed msvc-files from git
|
Hi Michael, I made a PR for my latest changes (including those made to django). The msvc files should hopefully have gone. cheers Tobias |
|
Thank you Tobias. I'm cleaning a few things up and then will get this merged. |
Hi Michael,
I finally found the time to work on the boostache code.
I could fix several deficits of the engine and think it is now a moustache-compliant template engine. The main problem was the missing context-stack (as we already discussed in Aspen): in contrast to the original implementation of the engine, which generates a data-driven call-hierarchy, moustache is not entirely data-driven (it can have nested contexts). For instance the original boostach couldn't handle correctly moustache code like in my example2.cpp (same data as original example2.cpp but with input
std::string input(
"Invoice"
"\n"
"{{#lines}}"
"inner start\n"
"{{#lines}}"
" {{item_code}} {{description}} {{amount}}\n"
"{{/lines}}"
"inner end\n"
"{{/lines}}"
);
the correct output is:
"Invoice
inner start
1234 teddy bear $23
1235 computer $9
inner end
inner start
1234 teddy bear $23
1235 computer $9
inner end"
)
I solved this by using a simple linked list of visited contexts, where the references to the contexts are stored in a variant over all types in the data-structure (computed by tmp-code in unificator.hpp). Thus, the stack is a fixed type and there is no infinite template recursion when the engine is compiled (which was the main problem of my first attempt). Furthermore, I changed the default rendering to a haskell-like dumping. In example3 I added overloads for render and test for a user-defined type (user_rendered_t) and it also works fine. Now, having moustache running we can then try and tackle django. (Which has some interesting features like "cycle" or "regroup" that will need further extensions of the engine.)
Any comment is appreciated!
Tobias