All Smarty template tags are enclosed within delimiters. By default, these delimiters are { and }, but they can be changed.
Some of syntaxes are:
Comments:
Template comments are surrounded by asterisks (*), and that is surrounded by the delimiter tags like: {* *}.
Variables
Template variables start with the dollar($) sign. They can contain numbers, letters and underscores, much like a PHP. You can reference arrays by index numerically or non-numerically. Also reference object properties and methods.
1. Config file variables are an exception to the $dollar syntax and the $smarty.config variable.
2. { * display the server variable "SERVER_NAME" ($_SERVER['SERVER_NAME'])*}
{$smarty.server.SERVER_NAME}
3. Math and embedding tags:
4. Defining Arrays:
5. Smarty "dot" syntax (note: embedded {} are used to address ambiguities):
Variables assigned from Smarty
This is a short-hand version of the {assign} function. You can assign values directly to the template, or assign values to array elements too.
Example1 :
{$myname="Sunil"}
My name is : {$myname}
DEMO :
Example2 :
{assign var=myname value="Sunil"}
My name is : {$myname}
DEMO :
Example3 :
{assign "myname" "Sunil"}
My name is : {$myname}
DEMO :
Attributes
Most of the functions take attributes that specify or modify their behavior. Attributes to Smarty functions are much
like HTML attributes. Static values don't have to be enclosed in quotes, but it is recommended for literal strings.
Variables may also be used, and should not be in quotes. Some attributes require boolean values (true or false).
These can be specified as either unquoted true, on, and yes, or false, off, and no.
Write the code in php so that when I run the following code in smarty I get the output as
India is my nation.I love India.
smarty code:-
{$country} is my nation.I love {$country}.