1 // vim: set expandtab tabstop=4 shiftwidth=4:
9 string HIT::getFileName(string blockname) {
10 return string(root + '/' + blockname + postfix);
13 string HIT::getFileContent(string filename) {
15 ifstream in(filename.c_str());
16 // FIXME - Verificar apertura.
19 cerr << "Can't read template file '" << filename << "'." << endl;
23 while (in.get(buff)) {
30 HIT::HIT(string root, string postfix): root(root), postfix(postfix) {}
32 string HIT::parse(string blockname, Hash& vars) {
33 string content = getFileContent(getFileName(blockname));
34 for (Hash::iterator i = vars.begin(); i != vars.end(); i++) {
35 string key = "{" + i->first + "}";
37 while ((pos = content.find(key)) != -1) {
39 cout << "Founded at pos " << pos << ", key '" << key << "' (len: "
40 << key.length() << "). Will be replaced with '" << i->second
43 content.replace(pos, key.length(), i->second);
45 cout << "New content: " << content << endl << endl << endl;