Differences between revisions 5 and 6
Revision 5 as of 2009-02-24 14:15:11
Size: 641
Editor: 147
Comment:
Revision 6 as of 2009-02-24 14:17:38
Size: 700
Editor: 147
Comment:
Deletions are marked like this. Additions are marked like this.
Line 14: Line 14:
V podadresári {{{templates}}} vytvoríme šablónu hello.html: V podadresári {{{templates}}} vytvoríme šablónu hello.html (Nazval som ju tu z technických
dôvodov {{{hello.txt}}}.)
Line 16: Line 17:
{{attachment:hello.html}} {{attachment:hello.txt}}

Hello, world verzia 3

Mať HTML kód vo vnútri view nie je dobrý nápad. HTML by malo byť iba v šablónach, aby sme mali jedno miesto, kde je HTML a nemuseli teda pri zmene HTML zasahovať do kódu.

Teraz ideme upraviť Hello, world verziu 2 tak, aby sme použili Template.

Keďže vytvárať Template zo stringu odporuje zásade v prvom odstavci, šablóny budú v súboroch.

Vytvoríme v adresári projektu hello podadresár s názvom napr. templates. V podadresári templates vytvoríme šablónu hello.html (Nazval som ju tu z technických dôvodov hello.txt.)

   1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   3 <html>
   4 <style type="text/css">
   5 h1 {
   6 	color:red;
   7 	font-style:normal;
   8 }
   9 </style>
  10 <head>
  11 <title>
  12 Hello, world v3
  13 </title>
  14 </head>
  15 <body>
  16 <h1>
  17 Hello, {{ who }}.
  18 </h1>
  19 </body>
  20 </html>

hello.txt

KMaDGWiki: ProgramovanieInternetovychAplikacii/HelloWorldV3 (last edited 2009-02-24 14:30:30 by 147)