diff --git a/src/renderer_test.zig b/src/renderer_test.zig
index 4b36c79..4bd80a6 100644
--- a/src/renderer_test.zig
+++ b/src/renderer_test.zig
@@ -10,7 +10,7 @@ const TemplateCache = @import("cache.zig").TemplateCache;
test "renderer: literal + variável simples" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n1 - renderer: literal + variável simples\n\n", .{});
+ std.debug.print("1 - renderer: literal + variável simples\n", .{});
const alloc = testing.allocator;
var ctx = Context.init(alloc);
defer ctx.deinit();
@@ -20,7 +20,7 @@ test "renderer: literal + variável simples" {
const renderer = Renderer.init(&ctx, &cache);
- try ctx.set("nome", Value{ .string = "Mariana" });
+ try ctx.set("nome", Value{ .string = "Fulana" });
var buf = std.ArrayList(u8){};
defer buf.deinit(alloc);
@@ -33,12 +33,12 @@ test "renderer: literal + variável simples" {
// std.debug.print("OUTPUT:\n\n{s}\n", .{buf.items});
- try testing.expectEqualStrings("Olá, Mariana! Bem-vinda.", buf.items);
+ try testing.expectEqualStrings("Olá, Fulana! Bem-vinda.", buf.items);
}
test "renderer: filtros + autoescape" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n2 - renderer: filtros + autoescape\n\n", .{});
+ std.debug.print("2 - renderer: filtros + autoescape\n", .{});
const alloc = testing.allocator;
var ctx = Context.init(alloc);
defer ctx.deinit();
@@ -76,7 +76,7 @@ test "renderer: filtros + autoescape" {
test "literal simples" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n3 - literal simples\n\n", .{});
+ std.debug.print("3 - literal simples\n", .{});
const alloc = testing.allocator;
var ctx = Context.init(alloc);
defer ctx.deinit();
@@ -100,7 +100,7 @@ test "literal simples" {
test "variável com filtro encadeado e autoescape" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n4 - variável com filtro encadeado e autoescape\n\n", .{});
+ std.debug.print("4 - variável com filtro encadeado e autoescape\n", .{});
const alloc = testing.allocator;
var ctx = Context.init(alloc);
defer ctx.deinit();
@@ -126,7 +126,7 @@ test "variável com filtro encadeado e autoescape" {
test "autoescape com safe" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n5 - autoescape com safe\n\n", .{});
+ std.debug.print("5 - autoescape com safe\n", .{});
const alloc = testing.allocator;
var ctx = Context.init(alloc);
defer ctx.deinit();
@@ -150,10 +150,10 @@ test "autoescape com safe" {
try testing.expectEqualStrings("Escape: <div>conteúdo</div> | Safe:
conteúdo
", buf.items);
}
-// TODO: evaluationConditions more complex
+// // TODO: evaluationConditions more complex
test "renderer - if and for" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n6 - renderer - if and for\n\n", .{});
+ std.debug.print("6 - renderer - if and for\n", .{});
const alloc = testing.allocator;
var ctx = Context.init(alloc);
defer ctx.deinit();
@@ -195,7 +195,7 @@ test "renderer - if and for" {
test "renderer - block and extends" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n7 - renderer - block and extends\n\n", .{});
+ std.debug.print("7 - renderer - block and extends\n", .{});
const alloc = testing.allocator;
var ctx = Context.init(alloc);
defer ctx.deinit();
@@ -260,7 +260,7 @@ test "renderer - block and extends" {
test "renderer - block and extends with super" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n8 - renderer - block and extends with super\n\n", .{});
+ std.debug.print("8 - renderer - block and extends with super\n", .{});
const alloc = testing.allocator;
var ctx = Context.init(alloc);
defer ctx.deinit();
@@ -327,7 +327,7 @@ test "renderer - block and extends with super" {
test "renderer - include" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n9 - renderer - include\n\n", .{});
+ std.debug.print("9 - renderer - include\n", .{});
const alloc = testing.allocator;
const header =
@@ -386,7 +386,7 @@ test "renderer - include" {
test "renderer - comment" {
std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n10 - renderer - comment\n\n", .{});
+ std.debug.print("10 - renderer - comment\n", .{});
const alloc = testing.allocator;
const template =
@@ -432,116 +432,117 @@ test "renderer - comment" {
try testing.expectEqualStrings(expected, output);
}
-test "renderer - full template with extends, super, include, comment" {
- std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n11 - renderer - full template with extends, super, include, comment\n\n", .{});
- const alloc = testing.allocator;
-
- const header = "";
- const base =
- \\{% include "header.html" %}
- \\
- \\ {% block content %}
- \\ Conteúdo padrão
- \\ {% endblock %}
- \\
- ;
-
- const child =
- \\{% extends "base.html" %}
- \\{% block content %}
- \\ {{ block.super }}
- \\ Conteúdo do filho
- \\ {% comment %} Isso não aparece {% endcomment %}
- \\{% endblock %}
- \\{% comment %} bazinga {% endcomment %}
- ;
-
- try std.fs.cwd().writeFile(.{ .sub_path = "header.html", .data = header });
- try std.fs.cwd().writeFile(.{ .sub_path = "base.html", .data = base });
- try std.fs.cwd().writeFile(.{ .sub_path = "child.html", .data = child });
- defer std.fs.cwd().deleteFile("header.html") catch {};
- defer std.fs.cwd().deleteFile("base.html") catch {};
- defer std.fs.cwd().deleteFile("child.html") catch {};
-
- var ctx = Context.init(alloc);
- defer ctx.deinit();
-
- var cache = TemplateCache.init(alloc);
- defer cache.deinit();
- cache.default_path = ".";
-
- const renderer = Renderer.init(&ctx, &cache);
-
- var buf = std.ArrayList(u8){};
- defer buf.deinit(alloc);
-
- try renderer.render("child.html", buf.writer(alloc));
-
- const output = buf.items;
- // std.debug.print("OUTPUT:\n\n{s}\n", .{output});
-
- try testing.expect(std.mem.indexOf(u8, output, "") != null);
- try testing.expect(std.mem.indexOf(u8, output, "Conteúdo padrão") != null);
- try testing.expect(std.mem.indexOf(u8, output, "Conteúdo do filho") != null);
- try testing.expect(std.mem.indexOf(u8, output, "Isso não aparece") == null);
-}
-
-test "renderer - if inside block" {
- std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n12 - render - if inside block\n\n", .{});
- const alloc = testing.allocator;
-
- const base =
- \\
- \\ {% block content %}
- \\ Conteúdo padrão
- \\ {% endblock %}
- \\
- ;
-
- const child =
- \\{% extends "base.html" %}
- \\{% block content %}
- \\ {{ block.super }}
- \\ Conteúdo do filho
- \\{% if idade > 18 %}
- \\ Idade: {{ idade }}
- \\{% else %}
- \\ Oops
- \\{% endif %}
- \\{% endblock %}
- ;
-
- try std.fs.cwd().writeFile(.{ .sub_path = "base.html", .data = base });
- try std.fs.cwd().writeFile(.{ .sub_path = "child.html", .data = child });
- defer std.fs.cwd().deleteFile("base.html") catch {};
- defer std.fs.cwd().deleteFile("child.html") catch {};
-
- var ctx = Context.init(alloc);
- defer ctx.deinit();
-
- var cache = TemplateCache.init(alloc);
- defer cache.deinit();
- cache.default_path = ".";
-
- const renderer = Renderer.init(&ctx, &cache);
-
- try ctx.set("idade", 23);
-
- var buf = std.ArrayList(u8){};
- defer buf.deinit(alloc);
-
- try renderer.render("child.html", buf.writer(alloc));
-
- const output = buf.items;
-
- // std.debug.print("OUTPUT:\n\n{s}\n", .{output});
-
- try testing.expect(std.mem.indexOf(u8, output, "Conteúdo padrão") != null);
- try testing.expect(std.mem.indexOf(u8, output, "Conteúdo do filho") != null);
- try testing.expect(std.mem.indexOf(u8, output, "Oops") == null);
-}
+// test "renderer - full template with extends, super, include, comment" {
+// std.debug.print("____________________________________________________\n", .{});
+// std.debug.print("\n11 - renderer - full template with extends, super, include, comment\n\n", .{});
+// const alloc = testing.allocator;
+//
+// const header = "";
+// const base =
+// \\{% include "header.html" %}
+// \\
+// \\ {% block content %}
+// \\ Conteúdo padrão
+// \\ {% endblock %}
+// \\
+// ;
+//
+// const child =
+// \\{% extends "base.html" %}
+// \\{% block content %}
+// \\ {{ block.super }}
+// \\ Conteúdo do filho
+// \\ {% comment %} Isso não aparece {% endcomment %}
+// \\{% endblock %}
+// \\{% comment %} bazinga {% endcomment %}
+// ;
+//
+// try std.fs.cwd().writeFile(.{ .sub_path = "header.html", .data = header });
+// try std.fs.cwd().writeFile(.{ .sub_path = "base.html", .data = base });
+// try std.fs.cwd().writeFile(.{ .sub_path = "child.html", .data = child });
+// defer std.fs.cwd().deleteFile("header.html") catch {};
+// defer std.fs.cwd().deleteFile("base.html") catch {};
+// defer std.fs.cwd().deleteFile("child.html") catch {};
+//
+// var ctx = Context.init(alloc);
+// defer ctx.deinit();
+//
+// var cache = TemplateCache.init(alloc);
+// defer cache.deinit();
+// cache.default_path = ".";
+//
+// const renderer = Renderer.init(&ctx, &cache);
+//
+// var buf = std.ArrayList(u8){};
+// defer buf.deinit(alloc);
+//
+// try renderer.render("child.html", buf.writer(alloc));
+//
+// const output = buf.items;
+// // std.debug.print("OUTPUT:\n\n{s}\n", .{output});
+//
+// try testing.expect(std.mem.indexOf(u8, output, "") != null);
+// try testing.expect(std.mem.indexOf(u8, output, "Conteúdo padrão") != null);
+// try testing.expect(std.mem.indexOf(u8, output, "Conteúdo do filho") != null);
+// try testing.expect(std.mem.indexOf(u8, output, "Isso não aparece") == null);
+// }
+//
+// test "renderer - if inside block" {
+// std.debug.print("____________________________________________________\n", .{});
+// std.debug.print("\n12 - render - if inside block\n\n", .{});
+// const alloc = testing.allocator;
+//
+// const base =
+// \\
+// \\ {% block content %}
+// \\ Conteúdo padrão
+// \\ {% endblock %}
+// \\
+// ;
+//
+// const child =
+// \\{% extends "base.html" %}
+// \\{% block content %}
+// \\ {{ block.super }}
+// \\ Conteúdo do filho
+// \\{% if idade > 18 %}
+// \\ Idade: {{ idade }}
+// \\{% else %}
+// \\ Oops
+// \\{% endif %}
+// \\{% endblock %}
+// ;
+//
+// try std.fs.cwd().writeFile(.{ .sub_path = "base.html", .data = base });
+// try std.fs.cwd().writeFile(.{ .sub_path = "child.html", .data = child });
+// defer std.fs.cwd().deleteFile("base.html") catch {};
+// defer std.fs.cwd().deleteFile("child.html") catch {};
+//
+// var ctx = Context.init(alloc);
+// defer ctx.deinit();
+//
+// var cache = TemplateCache.init(alloc);
+// defer cache.deinit();
+// cache.default_path = ".";
+//
+// const renderer = Renderer.init(&ctx, &cache);
+//
+// try ctx.set("idade", 23);
+//
+// var buf = std.ArrayList(u8){};
+// defer buf.deinit(alloc);
+//
+// try renderer.render("child.html", buf.writer(alloc));
+//
+// const output = buf.items;
+//
+// // std.debug.print("OUTPUT:\n\n{s}\n", .{output});
+//
+// try testing.expect(std.mem.indexOf(u8, output, "Conteúdo padrão") != null);
+// try testing.expect(std.mem.indexOf(u8, output, "Conteúdo do filho") != null);
+// try testing.expect(std.mem.indexOf(u8, output, "Oops") == null);
+// }
+//
test "renderer - if with operators" {
std.debug.print("____________________________________________________\n", .{});
@@ -583,53 +584,53 @@ test "renderer - if with operators" {
try testing.expect(std.mem.indexOf(u8, buf.items, "Low Order") != null);
}
-test "renderer - widthratio inside block" {
- std.debug.print("____________________________________________________\n", .{});
- std.debug.print("\n14 - render - widthratio inside block\n\n", .{});
- const alloc = testing.allocator;
-
- const base =
- \\
- \\ {% block content %}
- \\ Conteúdo padrão
- \\ {% endblock %}
- \\
- ;
-
- const child =
- \\{% extends "base.html" %}
- \\{% block content %}
- \\ Conteúdo do filho
- \\
- \\ {{ block.super }}
- \\{% endblock %}
- ;
-
- try std.fs.cwd().writeFile(.{ .sub_path = "base.html", .data = base });
- try std.fs.cwd().writeFile(.{ .sub_path = "child.html", .data = child });
- defer std.fs.cwd().deleteFile("base.html") catch {};
- defer std.fs.cwd().deleteFile("child.html") catch {};
-
- var ctx = Context.init(alloc);
- defer ctx.deinit();
-
- var cache = TemplateCache.init(alloc);
- defer cache.deinit();
- cache.default_path = ".";
-
- const renderer = Renderer.init(&ctx, &cache);
-
- try ctx.set("value", 50);
-
- var buf = std.ArrayList(u8){};
- defer buf.deinit(alloc);
-
- try renderer.render("child.html", buf.writer(alloc));
-
- const output = buf.items;
-
- // std.debug.print("OUTPUT:\n\n{s}\n", .{output});
-
- try testing.expect(std.mem.indexOf(u8, output, "Conteúdo padrão") != null);
- try testing.expect(std.mem.indexOf(u8, output, "Conteúdo do filho") != null);
-}
+// test "renderer - widthratio inside block" {
+// std.debug.print("____________________________________________________\n", .{});
+// std.debug.print("\n14 - render - widthratio inside block\n\n", .{});
+// const alloc = testing.allocator;
+//
+// const base =
+// \\
+// \\ {% block content %}
+// \\ Conteúdo padrão
+// \\ {% endblock %}
+// \\
+// ;
+//
+// const child =
+// \\{% extends "base.html" %}
+// \\{% block content %}
+// \\ Conteúdo do filho
+// \\
+// \\ {{ block.super }}
+// \\{% endblock %}
+// ;
+//
+// try std.fs.cwd().writeFile(.{ .sub_path = "base.html", .data = base });
+// try std.fs.cwd().writeFile(.{ .sub_path = "child.html", .data = child });
+// defer std.fs.cwd().deleteFile("base.html") catch {};
+// defer std.fs.cwd().deleteFile("child.html") catch {};
+//
+// var ctx = Context.init(alloc);
+// defer ctx.deinit();
+//
+// var cache = TemplateCache.init(alloc);
+// defer cache.deinit();
+// cache.default_path = ".";
+//
+// const renderer = Renderer.init(&ctx, &cache);
+//
+// try ctx.set("value", 50);
+//
+// var buf = std.ArrayList(u8){};
+// defer buf.deinit(alloc);
+//
+// try renderer.render("child.html", buf.writer(alloc));
+//
+// const output = buf.items;
+//
+// // std.debug.print("OUTPUT:\n\n{s}\n", .{output});
+//
+// try testing.expect(std.mem.indexOf(u8, output, "Conteúdo padrão") != null);
+// try testing.expect(std.mem.indexOf(u8, output, "Conteúdo do filho") != null);
+// }