read tag working.

This commit is contained in:
Brad Arant 2024-07-11 15:25:48 -07:00
parent e1be28e53b
commit 15f7b08d68
5 changed files with 12 additions and 6 deletions

View File

@ -3,6 +3,7 @@
#include "KeywordValue.h"
#include "Log.h"
#include "__mysql.h"
#include "__comment.h"
#include "__for.h"
#include "__if.h"
#include "__read.h"
@ -103,6 +104,9 @@ namespace jet {
if(ifTagName(in, "mysql")) {
__mysql _mysql(in, out, global);
continue;
} else if(ifTagName(in, "comment")) {
__comment _comment(in, out, global);
continue;
} else if(ifTagName(in, "for")) {
__for _for(in, out, global);
continue;

2
Tag.h
View File

@ -31,7 +31,7 @@ namespace jet {
bool output = true;
bool evaluate = true;
bool filterBlankLines = false;
bool trim = false;
bool trimLines = false;
bool cleanWhitespace = false;
private:

View File

@ -7,15 +7,14 @@
namespace jet {
__read::__read(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
if(!variableDefined(coreutils::ZString("file")))
if(!variableDefined("file"))
throw coreutils::Exception("file keyword must be specified.");
if(!variableDefined("name"))
throw coreutils::Exception("name keyword must be specified.");
if(hasContainer)
throw coreutils::Exception("read tag does not have a container.");
fd = open(variables["file"].c_str(), O_RDONLY);
while(len = read(fd, &buffer, sizeof(buffer - 1))) {
buffer[len] = 0;
out << buffer;
}
global.variables[variables["name"]].read(fd);
close(fd);
}

BIN
testjet

Binary file not shown.

View File

@ -6,6 +6,7 @@
int main(int argc, char **argv) {
coreutils::ZString data("<jet name=\"localname\" filterblanklines=\"true\">\n"
" <comment>This is a comment and should not show up in the output.</comment>\n"
" <html>\n"
" <set name=\"ix\" value=\"1\" />\n"
" <set name=\"theexpr\" expr=\"true\" />\n"
@ -31,6 +32,8 @@ int main(int argc, char **argv) {
" </for>\n"
" <call pgm=\"/usr/bin/ls\" arg1=\"-al\" name=\"ls\" />\n"
" $[ls]\n"
" <read file=\"compile\" name=\"file\" />\n"
" $[file]\n"
" </html>\n"
"</jet>\n");