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.FileSystemResourceLoader; 22 23 import java.io.IOException; 24 25 /** 26 * Command-line template renderer. 27 * 28 * Usage: JSilverTest file.cs [file.hdf file2.hdf ...] 29 */ 30 public class JSilverTest { main(String[] args)31 public static void main(String[] args) throws IOException { 32 if (args.length < 1) { 33 System.out.println("Usage: JSilverTest file.cs [file.hdf file2.hdf ...]"); 34 System.exit(1); 35 } 36 37 // Load resources from filesystem, relative to the current directory. 38 JSilver jSilver = new JSilver(new FileSystemResourceLoader(".")); 39 40 // Load data. 41 Data data = jSilver.createData(); 42 for (int i = 1; i < args.length; i++) { 43 jSilver.loadData(args[i], data); 44 } 45 46 // Render template to System.out. 47 jSilver.render(args[0], data, System.out); 48 } 49 } 50