• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.clearsilver.jsilver.examples.basic;
18 
19 import com.google.clearsilver.jsilver.JSilver;
20 import com.google.clearsilver.jsilver.data.Data;
21 import com.google.clearsilver.jsilver.resourceloader.ClassResourceLoader;
22 
23 import java.io.IOException;
24 
25 /**
26  * Hello world of templates.
27  */
28 public class HelloWorld {
29 
main(String[] args)30   public static void main(String[] args) throws IOException {
31 
32     // Load resources (e.g. templates) from classpath, along side this class.
33     JSilver jSilver = new JSilver(new ClassResourceLoader(HelloWorld.class));
34 
35     // Set up some data.
36     Data data = jSilver.createData();
37     data.setValue("name.first", "Mr");
38     data.setValue("name.last", "Man");
39 
40     // Render template to System.out.
41     jSilver.render("hello-world.cs", data, System.out);
42   }
43 }
44