Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

html template, ccs or PHP for decoration is posible? #37

Closed
domonetic opened this issue May 25, 2013 · 14 comments
Closed

html template, ccs or PHP for decoration is posible? #37

domonetic opened this issue May 25, 2013 · 14 comments
Labels

Comments

@domonetic
Copy link

In delphi to create a webserver was the ability to use templates with labels {mytag} that helped replace them with values ​​or objects.
Brookframework does the hard work, but to generate a beautiful web, it takes much work to code. You can do that using php generate templates or to improve the appearance?

En delphi al crear un webserver se tenia la posibilidad de usar plantillas con etiquetas {mytag} que ayudaban a reemplazarlas por valores u objetos.
Brookframework hace el trabajo duro pero para generar una pagina bella lleva mucho trabajo por codigo. Se puede hacer que el uso de plantillas o generar php para mejorar el aspecto?

@leledumbo
Copy link
Collaborator

Original fcl-web which brook is based on has fptemplate (moved to fcl-base since it's proven to be usable outside of web environment)
silvio has jtemplate
I have qtemplate and view (not yet uploaded, I'll do later)

Each has different features

@silvioprog
Copy link
Owner

The JTemplate link is: https://github.com/silvioprog/jtemplate
What the link of QTemplate?

@leledumbo
Copy link
Collaborator

What the link of QTemplate?

I haven't uploaded it, because I develop in office (which I haven't sent to my home computer yet, and my office internet is very limited). I'm going to send it home today.

However, I also have view: https://dl.dropboxusercontent.com/u/22124591/view.tar.gz

Both are built on top of FPTemplate, with different concept. View is more passive, for instance with the following template:

$(News
  [Content=
    <div class="news">
      <div class="post-title">~PostTitle</div>
      <div class="posted-by">Posted by ~Poster</div>
      <div class="date">on ~Date</div>
      <div class="post-content">~PostContent</div>
    </div>
  ]
  [Separator=<hr />]
)

Example code to use them:

procedure THomeAction.Get;
var
  HomeView: TView;
  TempVar: TViewVariable;
begin
  StyleSheets.Add('news.css');
  HomeView := TView.Create('templates/home.html');

  TempVar := HomeView['News'];

  TempVar.Value := StringsReplace(
    TempVar['Content'],
    ['~PostTitle','~Poster','~Date','~PostContent'],
    ['Test Title 1','Admin',DateTimeToStr(Now),'<p>Test Post 1</p>'],
    [rfReplaceAll]
  );
  TempVar.Value := TempVar.Value + TempVar['Separator'];
  TempVar.Value := TempVar.Value + StringsReplace(
    TempVar['Content'],
    ['~PostTitle','~Poster','~Date','~PostContent'],
    ['Test Title 2','Admin',DateTimeToStr(Now),'<p>Test Post 2</p>'],
    [rfReplaceAll]
  );

  Content := HomeView.GetContent;
  HomeView.Free;
end;

QTemplate on the other hand still preserve the event driven approach, only now for each tag, user must create a callback instead of centralized in a single method. The class is the one responsible for tag checking and calling the appropriate callback.

ATM, QTemplate is faster because it traverse the template only once, while View does it twice (first to get the tags, second to replace them).

@leledumbo
Copy link
Collaborator

@silvioprog
Copy link
Owner

Are you versioning the QTemplate? It can be a Book plugin.

@leledumbo
Copy link
Collaborator

I'm uploading to bitbucket

@leledumbo
Copy link
Collaborator

I've improved the test program quite a lot to show the usefulness. I don't know whether it's a good idea to make it part of Brook (jtemplate is not part of Brook as well, isn't it?). Besides, I like Mercurial much better than Git due to sane and more powerful and easier to use GUI frontend (TortoiseHg).

@silvioprog
Copy link
Owner

To do its very simple, add "Brook plugin" on README of your project and make a small demo showing how to use the plugin with Brook.

I use Github because it is more accessed than Bitbuket, and the interface is very clean and intuitive. My Git GUI is SmartGIT, it is free (for non comercial use) and have several features to manage GIT. It runs on Linux/Windows too, with the same interface. :)

@silvioprog
Copy link
Owner

... soon, I will create the page "http://brookframework.org/plugins" and upload all Brook plugins for it. :)

@leledumbo
Copy link
Collaborator

I'll see whether it's possible to use both git and mercurial for the same repo directory. both seems to use one hidden folder on project top dir only (.git / .hg) so in theory there should be no problem

Sent from my Android phone with mail.com Mail. Please excuse my brevity.

@leledumbo
Copy link
Collaborator

Cloned in github, added sample usage with brook (taken from brook static file broker demo): https://github.com/leledumbo/QTemplate

@silvioprog
Copy link
Owner

Thank you very much! Soon I'll upload all Brook plugins to: http://brookframework.org/plugins 👍

@silvioprog
Copy link
Owner

Can I close this issue buddy?

@silvioprog
Copy link
Owner

Closed for lack feedback. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants