Skip to content

Latest commit

 

History

History
80 lines (64 loc) · 2.5 KB

README.md

File metadata and controls

80 lines (64 loc) · 2.5 KB

rumal (রুমাল) is a tiny header only XML/HTML/SVG/CSS/Javascript* Generator C++ library

License pipeline status Documentation Status Codacy Badge Total alerts Language grade: C/C++

Composing XML/HTML/SVG/CSS/Javascript* fragments do not involve any heap memory allocation. Both HTML and CSS blocks can be nested. An HTML block refers to an HTML tag whereas a CSS block refers to a CSS declarations block. Nesting a CSS block inside another results into nested CSS declaration.

Basic Example

#include <iostream>
#include <rumal/rumal.hpp>

int main(int argc, char **argv){
    using namespace rumal::html::attrs;
    using namespace rumal::html::tags;
    using namespace rumal::css;
    using namespace rumal::css::props;
   
    std::cout << div(_id(42) / _class("test"),
                    span(_id(43) / _class("test"), "Hello"),
                    span("World")
                ) << std::endl;
    
    std::cout << select(".heading", 
                    position("relative") / 
                    display("block"), 
                ) << std::endl;
    return 0;
}

Nested CSS

using namespace rumal::css;
using namespace rumal::css::props;

select(".main", 
      display("block") 
    / position("relative"), 
    select(".heading", 
          display("block") 
        / position("relative")
    )
) / select(".container", 
      display("block") 
    / position("relative")
);

The above example produces the following CSS.

.container{
    position: relative; 
    display: block;
}

.main{
    position: relative;
    display: block;
}

.main > .heading{
    position: relative;
    display: block;
}

HTML attributes

HTML Tags