Re: [Cppcms-users] razor like syntax for templates
Brought to you by:
artyom-beilis
|
From: Lee E. <lee...@gm...> - 2013-05-20 21:36:25
|
On Mon, May 20, 2013 at 1:58 PM, Artyom Beilis <art...@ya...> wrote:
>
>
>
> >> 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.
>
> That is a valid point - but perhaps you look at it the wrong way - you
supply C++ API for providing templates, and loading them on the fly. This
is the part that should be inside the CppCMS project
The template system(s) are a separate extension to the CppCMS, you need to
provide continued support for one such system, but others can be
implemented on the side and maintained by others from the community. And if
someone will provide a better template system then the "officially"
supported system, you can always drop the official system maintanance in
favor of recomending the better system.
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.
>
> True, and i have done some improvments - but it was hard for my,
especially since python is not a native language for me (this is something
that i probably need to change).
But the current template system has a few design problems in my opinion
that throwing it away and developing a new is a viable option in my eyes.
The most problematic of the design issues in my eyes becomes visible when
you look at the C++ code that gets generated for <%= xxx %>
This translates into the C++ code:
out()<<cppcms::filters::escape(content.xxx);
The problem here is the content. prefix - this means that the strongest
component in any C++ suite, the compiler, was robbed of its strength of
finding out what xxx refers too. This same problem is repeated in the flow
blocks - but there it is less obvious.
The other less major problem i have with the CppCMS template system is the
forms & widgets system.
the csrf token is a great addition, but the form widgets rarely give you
what you really want in the resulting HTML. In order to generate the right
html you need to either generate your own widget (inheritance is a great
tool) or use the widget properties and use then in html that you generate
on your own. so generally the only thing that the widget does for you is
parse the value recieved from the client into the proper format - this can
be done differently using the request existing API
This is not a major issue simply since noone is forced to use the widget
system at all. But the existence of them as part of the CppCMS package
suggest that they are a recomended way to build your forms, and they are a
limitation if you want to build reach HTML apps.
3. I need 100% backward compatibility guarantee, such that if there is some
> @ in HTML code
> they would not mess.
>
> You need 100% compatibility if you enahnce the existing template system.
If you create a new one nothing stopps you from declaring a whole new set
of rules and guidelines for how to build templates using the new system.
The only two things that matter are compatibility with the framework skin
loader, and that it will be easier to write your html code using the new
template system.
> 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.
>
> I agree - this is the one thing i dislike about @ syntax
>> 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.
>
> The major advantages that razor has over its predecesor aspx/ascx/master
are:
getting simpler files that are all the same (razor files that generate
content and contain code) instead of have your code span across multiple
object types for different usage. Support for partial rendering of one
razor file from another as opposed to using special object types for that.
Simpler syntax, that is closer to the client technology (you actually write
html & javascript inside your razor files, where with aspx you used widgets
to get what you wanted done)
cppcms_tmpl_cc suffer from similar problems to those of aspx/ascx/master:
in order you define a template that is used as master - you use
inheritance. you ca call from one template into the other, but it is not
that easy to do. The syntax in the templates could be simpler, especially
for the control blocks. And as i wrote above, i dislike the widgets
>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.
>
> I also prefer git, but git-svn is a great tool, and it also supports
importing ALL svn history including merge information. But i agree - no
rush. The time in invest in such a move is a heavy price on its own.
>
> 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/
>
>
>
> ------------------------------------------------------------------------------
> AlienVault Unified Security Management (USM) platform delivers complete
> security visibility with the essential security capabilities. Easily and
> efficiently configure, manage, and operate all of your security controls
> from a single console and one unified framework. Download a free trial.
> http://p.sf.net/sfu/alienvault_d2d
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
--
--
lee
Lee Elenbaas
lee...@gm...
|