Skip to content

Commit

Permalink
Issue rep-movsd#27: Implement "for" tag
Browse files Browse the repository at this point in the history
  • Loading branch information
rep-movsd committed Nov 20, 2017
1 parent b417a43 commit b3e0da1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
14 changes: 7 additions & 7 deletions seephit.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,8 @@ struct parser
check_eos();
ON_ERR_RETURN false;


// Swallow any space
eat_space();


// Is it an ID tag
if(name == g_symID)
Expand All @@ -334,8 +332,8 @@ struct parser
}
else
{
const int nAttrs = sizeof(arrBoolAttrs)/sizeof(arrBoolAttrs[0]);
if(find_arr(arrBoolAttrs, nAttrs, name.m_pBeg) == -1)
const int nAttrs = sizeof(g_arrBoolAttrs)/sizeof(g_arrBoolAttrs[0]);
if(find_arr(g_arrBoolAttrs, nAttrs, name.m_pBeg) == -1)
{
PARSE_ERR(Error_Expecting_a_value_for_attribute);
}
Expand Down Expand Up @@ -401,8 +399,10 @@ struct parser
eat_space();

// Check if valid tag
const int nTags = sizeof(arrTags)/sizeof(arrTags[0]);
if(find_arr(arrTags, nTags, sym.m_pBeg) == -1)
const int nTags = sizeof(g_arrTags)/sizeof(g_arrTags[0]);
const int nCtrlTags = sizeof(g_arrCtrlTags)/sizeof(g_arrCtrlTags[0]);

if(find_arr(g_arrCtrlTags, nCtrlTags, sym.m_pBeg) == -1 && find_arr(g_arrTags, nTags, sym.m_pBeg) == -1)
{
WITH_SAVE_POS
{
Expand All @@ -411,7 +411,7 @@ struct parser
}
}

// Parse attributes
// Parse all attributes
while(parse_attrs(attrs));
ON_ERR_RETURN false;

Expand Down
10 changes: 8 additions & 2 deletions tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ constexpr const char* arrVoidTags[] =
"source"
};

constexpr const char *arrBoolAttrs[] =
constexpr const char *g_arrBoolAttrs[] =
{
"checked",
"compact",
Expand All @@ -34,7 +34,7 @@ constexpr const char *arrBoolAttrs[] =
"selected",
};

constexpr const char *arrTags[] =
constexpr const char *g_arrTags[] =
{
"a",
"abbr",
Expand Down Expand Up @@ -180,4 +180,10 @@ constexpr const char *arrTags[] =
"xmp",
};

constexpr const char *g_arrCtrlTags[] =
{
"for"
};


#endif
2 changes: 1 addition & 1 deletion test/loop.spt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
R"*(
<for n=1 to=10 inc=1 >
<div>
item%n%
item{{n}}
</div>
</for>
)*"_html;

0 comments on commit b3e0da1

Please sign in to comment.