[−][src]Function minifier::js::aggregate_strings_into_array_with_separation
pub fn aggregate_strings_into_array_with_separation<'a, 'b: 'a>(
tokens: Tokens<'a>,
array_name: &str,
separation_token: Token<'b>
) -> Tokens<'a>
Exactly like aggregate_strings_into_array
except this one expects a separation token
to be passed. This token will be placed between the created array for the
strings aggregation and the rest.
Example
Let's add a backline between the created variables and the rest of the code:
extern crate minifier; use minifier::js::{ aggregate_strings_into_array_with_separation, clean_tokens, simple_minify, Token, ReservedChar, }; use std::fs; fn main() { let content = fs::read("some_file.js").expect("file not found"); let source = String::from_utf8_lossy(&content); let s = simple_minify(&source); // First we get the tokens list. let s = s.apply(|f| { aggregate_strings_into_array_with_separation(f, "R", Token::Char(ReservedChar::Backline)) }) // We add a backline between the variable and the rest. .apply(clean_tokens) // We clean the tokens. .to_string(); // And we finally convert to string. println!("result: {}", s); }