Re: [Cppcms-users] razor like syntax for templates
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2013-05-20 10:58:16
|
>> if you think on the second approach - it will be much faster, i would
>> base it on the existing cppcms_tmpl_cc script, but the end result will
>> not feel razor IMO since you will not be able to use C++ language
>> constructs freely inside the page
>I tried this. I replaced all the regex pattern with a simple @ and it
>works, but it's still not what I want. This is because of you have still
>to write
>@if
>...
>@endif
>and this sucks! Really. So in fact I'd like to write the cppcms_tmpl_cc
>new and make that the thing I want. But let's see what I can do in the
>next few weeks.
Three points:
1. I don't really want to support two versions of cppcms_tmpl_cc.
2. I think, many things can be improved even in the current version, for example
allow the statement to be split over multiple lines, improve WS handling etc.
3. I need 100% backward compatibility guarantee, such that if there is some @ in HTML code
they would not mess.
There is a reason that <% %> are used - they are not HTML/XML and not a part of HTML/XML
so they are good escape sequences, on the other hand "@" is generic character that can
exist in any place in HTML.
Most of template languages use such a syntax that may better or worth.
The question finally if it works well... if you don't like @if and @endif you
may write entire HTML generation in plane C++... Of course it is not handily.
>> If you think about the first - i suggest do it from scratch, and
>> generate cpp (and perhaps h files) from the template
>> file independently of the cppcms_tmpl_cc - also adopt some limitation
>> on the generated cpp code that will make your life easier (like each
>> file have only one implicit template in it - or that @section "name"{
>> ... } will define another template, but have it follow a predefined
>> signature), and i would also adopt a separate extension like cpphtml
>> to follow the razor convention for c# and vb
>
>Just to clarify. I will not convert the whole razor c# language to
>cppcms_tmpl, because this is too big for me (, now). I will create a
>basic template for using if-statements, for/while loops and variables.
>I will orientate myself to the existing commands [0]. If you don't like
>it, feel free to write what has to be improved or changed regarding to
>the currhttp://cppcms.com/wikipp/en/page/cppcms_1x_templates_comment
>standard.
>> i do not have the time to pick up this project on my own right now -
>> but if you say what direction you are going, i'll try and help
>Me neither. I study in the 4th semester and it's not easy as some of you
>might know. And that has more priority than this. Sorry about that, but
>whenever I have some time, I will spend some of it.
>
See the most important things what this would provide you?
Better syntax, maybe but would it give you more power? On your current
suggestion - not.
And that is most important, some syntactic sugar would be helpful, but
full templates system redesign... I'd rather prefer to rewrite it in
C++ and combine it with clang/LLVM so I can compile my templates on the fly.
Which is a way cooler thing to do - and it really provides more power
to user - i.e. fully dynamic templates - not only automatic shared objects
reloading.
>Maybe I will setup a git repo for this in the next days, so you can see
>the actual development and say: "Stop! that's crap". and put your
>patches to it. I would really appreciate that.
>
>Regards
>Marcel
>
>[0] http://cppcms.com/wikipp/en/page/cppcms_1x_templates_comm
>
>Oh by the way, Artyom.... why not migrating to git? Git has a nice
>feature for this ;) and of course it's 1000x better than svn.
>https://www.youtube.com/watch?v=4XpnKHJAok8
>
About git... You know everything is a question of time.
Can you convert entire svn history including, MERGE INFORMATION,
branches, commits etc? I looked for one and neither one was simple
or fully preserving the information.
This is not a priority...
You want to use git? Use git-svn - it is nice tool that allows
you to work locally on git.
Bottom line...
I don't think that "redesign" for razor is kind of thing would be good,
it would rather increase workload on me as a primary developer - to
support both versions.
Improvements are more than welcome, but fully new concept - I don't think that
"razor" is really such a killing feature to use spend the time on it.
Artyom Beilis
--------------
CppCMS - C++ Web Framework: http://cppcms.com/
CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
|