void LessStylesheet::process(Stylesheet &s, ProcessingContext &context) { std::list<Extension>* extensions; std::list<Ruleset*>::iterator r_it; std::list<Extension>::iterator e_it; context.pushScope(variables); this->context = &context; Stylesheet::process(s); context.popScope(); // post processing extensions = &context.getExtensions(); for (r_it = s.getRulesets().begin(); r_it != s.getRulesets().end(); r_it++) { for (e_it = extensions->begin(); e_it != extensions->end(); e_it++) { (*e_it).updateSelector((*r_it)->getSelector()); } } }
// block in value TEST(CssParserTest, BlockValue) { istringstream in("selector {key: {value}}"); CssTokenizer t(&in); CssParser p(&t); Stylesheet s; Declaration* d; p.parseStylesheet(&s); ASSERT_EQ(1, s.getRulesets()->size()); ASSERT_EQ(1, s.getRulesets()->at(0)->getDeclarations()->size()); d = s.getRulesets()->at(0)->getDeclarations()->at(0); ASSERT_STREQ("key", d->getProperty()->c_str()); ASSERT_STREQ("{value}", d->getValue()->toString()->c_str()); }
// Rulesets TEST(CssParserTest, Ruleset) { istringstream in("selector {key: value;}"); CssTokenizer t(&in); CssParser p(&t); Stylesheet s; Ruleset* set; Declaration* d; p.parseStylesheet(&s); ASSERT_EQ(1, s.getRulesets()->size()); set = s.getRulesets()->at(0); ASSERT_STREQ("selector", set->getSelector()->toString()->c_str()); ASSERT_EQ(1, set->getDeclarations()->size()); d = set->getDeclarations()->at(0); ASSERT_STREQ("key", d->getProperty()->c_str()); ASSERT_STREQ("value", d->getValue()->toString()->c_str()); }