<commit_before># The Righteous Markup Lever

*v1.5.0* 
## A Quick and Dirty Tour

### Render A Tag, Any Tag...

Most common HTML tags have convenience methods which can be called like so:

	RML.a();
	
	=> <a></a>
	
If a tag doesn't require any attributes you can pass in its content simply as
a string argument:

	RML.span('Hello World!');
	
	=> <span>Hello World!</span>
	
Tags will require attributes though, so pass a 'config' object to a method with  
properties and values which reflect the attributes you want rendered:

	RML.div({
		id: 'foo',
		_class: 'bar'
	});
	
	=> <div id='foo' class='bar'></div>
	
We use _class in the config object to circumvent any issues with the reserved 
keyword 'class'.

#### The Content Property

If a config object has a `content` property its value is placed between the 
opening and closing tags. In the case of a string (or a number) the value is 
written as is:

	RML.div({
		id: 'foo',
		_class: 'bar',
		content: 'Important stuff'
	});
	
	=> <div id='foo' class='bar'>Important stuff</div>
	
If the value of the content property is a function, that function will be called.

	RML.div({
	    id: 'foo',
	    _class: 'bar',
	    content: function() {
	        var data = {
	        	stuff: 'Important stuff'
			};
			return data.stuff;
	    }
	});
	
	=> <div id='foo' class='bar'>Important stuff</div>

This feature, obviously, can have much more powerful uses than the above example, 
and has proven to be very effective for elements whose contents need to be
fetched and parsed asynchronously.

##### Arrays as Content

You can have an array as content in either a tag with no attributes:

	RML.div(['I', 'am', 'an', 'array']);
	
	=> <div>Iamanarray</div>
	
This has one obvious problem, the array is joined and return with no spaces
between items. This is a design decision as I have no way to know what any 
given array may contain, or how it needs to be rendered. The solution is to 
provide an override argument passed to the tag method itself. You lose the 
convenience method, but you gain the ability to join an array with any delimiter
you wish:

	RML.tag('div', ['I', 'am', 'an', 'array'], 0, ' ');
	
	=> <div>I am an array</div>
	
Or, 

	RML.tag('div', ['I', 'am', 'an', 'array'], 0, '-');
	
	=> <div>I-am-an-array</div>

Also, the `content` attribute of a config object may contain an array. The same
procedure as above would apply for rendering it how you wanted. With commas for 
example:

	RML.tag('div', {
		id: 'green',
		_class: 'eggs',
		content: ['I', 'am', 'an', 'array', 'too']
	}, 0, ',');
	
	=> <div id='green' class='eggs'>I,am,an,array,too</div>

### The Siblings Method

To abstract out the common pattern of joining string arrays or using `+=`, you can now call `RML.siblings()` with any number of arguments:

	RML.ul({
    	id: 'list',
    	content: RML.siblings(
			RML.li('some'),
			RML.li('sibling'),
			RML.li('elements')
		);
	});
	
	=> <ul id="list"><li>some</li><li>sibling</li><li>elements</li></ul>

### The Tags Object

RML dynamically creates convenience methods for tags based on the key-value 
pairs in the 'tags' object. <commit_msg>Refactoring all around, and an updated README<commit_after># The Righteous Markup Lever

*v1.5.0* 
## A Quick and Dirty Tour

### Render A Tag, Any Tag...

Most common HTML tags have convenience methods which can be called like so:

	RML.a();
	
	=> <a></a>
	
If a tag doesn't require any attributes you can pass in its content simply as
a string argument:

	RML.span('Hello World!');
	
	=> <span>Hello World!</span>
	
Tags will require attributes though, so pass a 'config' object to a method with  
properties and values which reflect the attributes you want rendered:

	RML.div({
		id: 'foo',
		_class: 'bar'
	});
	
	=> <div id='foo' class='bar'></div>
	
We use _class in the config object to circumvent any issues with the reserved 
keyword 'class'.

#### The Content Property

If a config object has a `content` property its value is placed between the 
opening and closing tags. In the case of a string (or a number) the value is 
written as is:

	RML.div({
		id: 'foo',
		_class: 'bar',
		content: 'Important stuff'
	});
	
	=> <div id='foo' class='bar'>Important stuff</div>
	
If the value of the content property is a function, that function will be called.

	RML.div({
	    id: 'foo',
	    _class: 'bar',
	    content: function() {
	        var data = {
	        	stuff: 'Important stuff'
			};
			return data.stuff;
	    }
	});
	
	=> <div id='foo' class='bar'>Important stuff</div>

This feature, obviously, can have much more powerful uses than the above example, 
and has proven to be very effective for elements whose contents need to be
fetched and parsed asynchronously.

##### Arrays as Content

You can have an array as content for a tag. Here, with no attributes:

	RML.div(['I', 'am', 'an', 'array']);
	
	=> <div>Iamanarray</div>
	
This has one obvious problem, the array is joined and return with no spaces
between items. This is a design decision as I have no way to know what any 
given array may contain, or how it needs to be rendered. The solution is to 
provide an override argument passed to the tag method itself. You lose the 
convenience method, but you gain the ability to join an array with any delimiter
you wish:

	RML.tag('div', ['I', 'am', 'an', 'array'], 0, ' ');
	
	=> <div>I am an array</div>
	
Dashes:, 

	RML.tag('div', ['I', 'am', 'an', 'array'], 0, '-');
	
	=> <div>I-am-an-array</div>

And here, in the `content` attribute of a config object. The same
procedure as above would apply for rendering it how you wanted. With commas for 
example:

	RML.tag('div', {
		id: 'green',
		_class: 'eggs',
		content: ['I', 'am', 'an', 'array', 'too']
	}, 0, ',');
	
	=> <div id='green' class='eggs'>I,am,an,array,too</div>

### The Siblings Method

To abstract out the common pattern of joining string arrays or using `+=`, you can now call `RML.siblings()` with any number of arguments:

	RML.ul({
    	id: 'list',
    	content: RML.siblings(
			RML.li('some'),
			RML.li('sibling'),
			RML.li('elements')
		);
	});
	
	=> <ul id="list"><li>some</li><li>sibling</li><li>elements</li></ul>

### The Tags Object

RML dynamically creates convenience methods for tags based on the key-value 
pairs in the 'tags' object. 
{'fraction_non_alphanumeric': 0.1314194577352472, 'fraction_numerical': 0.0019138755980861245, 'mean_word_length': 3.5773722627737228, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3330070', 'n_tokens_mistral': 2135, 'n_tokens_neox': 1985, 'n_words': 854}