Evaluate template args for missing templates else en.w flags will sometimes be large

v3.3.4
gnosygnu 8 years ago
parent c98404a8fe
commit d6aeb2e177

@ -19,5 +19,5 @@ package gplx.xowa.parsers.tmpls; import gplx.*; import gplx.xowa.*; import gplx.
public class Xot_compile_data {
public boolean OnlyInclude_exists;
public boolean Arg_nde_has_key() {return arg_nde_has_key;} public Xot_compile_data Arg_nde_has_key_(boolean v) {arg_nde_has_key = v; return this;} private boolean arg_nde_has_key;
public static final Xot_compile_data Null = new Xot_compile_data();
public static final Xot_compile_data Noop = new Xot_compile_data();
}

@ -77,7 +77,7 @@ public class Xot_defn_tmpl implements Xot_defn {
byte[] new_data = Extract_onlyinclude(data_raw, wiki.Utl__bfr_mkr());
Xop_ctx new_ctx = Xop_ctx.New__sub(wiki, ctx, page); // COMMENT:changed from ctx.Page() to page; DATE:2016-07-11
Xot_defn_tmpl tmpl = wiki.Parser_mgr().Main().Parse_text_to_defn_obj(new_ctx, new_ctx.Tkn_mkr(), wiki.Ns_mgr().Ns_template(), Bry_.Empty, new_data);
tmpl.Root().Tmpl_compile(new_ctx, new_data, Xot_compile_data.Null);
tmpl.Root().Tmpl_compile(new_ctx, new_data, Xot_compile_data.Noop);
data_raw = new_data;
root = tmpl.Root();
}

@ -199,13 +199,15 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
bfr.Add(Xop_curly_bgn_lxr.Hook).Add(name_ary_orig).Add(Xop_curly_end_lxr.Hook);
return false;
}
else { // output entire tmpl_src WITH args; used to output name only which broke pages; PAGE:en.w:Flag_of_Greenland; DATE:2016-06-21
else {// output entire tmpl_src WITH args; used to output name only which broke pages; PAGE:en.w:Flag_of_Greenland; DATE:2016-06-21
bfr.Add(Xop_curly_bgn_lxr.Hook);
bfr.Add(name_ary);
for (int i = 0; i < args_len; ++i) {
Arg_nde_tkn nde = this.Args_get_by_idx(i);
bfr.Add_byte(Byte_ascii.Pipe);
bfr.Add_mid(src, nde.Src_bgn(), nde.Src_end());
// must evaluate args; "size={{{size|}}}" must become "size="; PAGE:en.w:Europe; en.w:Template:Country_data_Guernsey DATE:2016-10-13
nde.Tmpl_compile(ctx, src, Xot_compile_data.Noop);
nde.Tmpl_evaluate(ctx, src, caller, bfr);
}
bfr.Add(Xop_curly_end_lxr.Hook);
return false;

@ -31,6 +31,12 @@ public class Xot_invk_wkr__missing__tst {
fxt.Test_parse_tmpl_str("{{test_template}}", "{{{{{1}}}| a | b }}"); // NOTE: this should include spaces (" {{{1}}} "), but for now, ignore
fxt.Init_defn_clear();
}
@Test public void Missing__evaluate_optional() { // PURPOSE: missing title should still evaulate optional args; "{{{a|}}}" -> ""; PAGE:en.w:Europe; en.w:Template:Country_data_Guernsey DATE:2016-10-13
fxt.Init_defn_clear();
fxt.Init_defn_add("test_template", "{{ {{{1}}} | {{{a|}}} | b }}");
fxt.Test_parse_tmpl_str("{{test_template}}", "{{{{{1}}}| | b }}"); // NOTE: "| |" not "| {{{a|}}} |"
fxt.Init_defn_clear();
}
@Test public void Missing_foreign() {
Xow_ns ns = fxt.Wiki().Ns_mgr().Ns_template();
byte[] old_ns = ns.Name_db();

Loading…
Cancel
Save