Creating your own template engine in JavaScript: part 1.5

Tuesday, November 19, 2013 Posted by Ruslan Matveev 3 comments
It's been a while since I had a time to write something here. Yeah yeah yeah, I'm just lazy guy, but I will try to do it more often. Last time I've promised you second part of this never ending story, it's been about a year ago! I learn many new tricks, so before going into the second part of "creating your own template engine in JavaScript", I've decided to rewrite my uber Tokenizer from the first part. What was wrong with that? Well many things:

  • - too many strings and identifiers that I had to use every time when I ask it for a token
  • - escaping regular expressions in the string literals was really pain in the ass
  • - ignored tokens (which is sometimes very nice to have) were completely ignored and there was no way to read them somehow
  • - all this context switching things were looking very nice a year ago, but now I would make it a bit different