![]() There are a few things I found extremely helpful to my workflow while building out the Craft-Twig Language Grammar. It was nice to know that I wasn't the only person struggling for weeks of time making sense of these things and his post has several worthwhile gotchas to look out for and tips that came in handy. I'm also thankful to Matt Neuburg who took the time to document his own experience: Writing a TextMate Grammar: Some Lessons Learned. After enough fussing around and enough things finally clicking, I found myself referring back to the docs regularly and they now make a lot more sense in helping me tie together the things I learned along the way. They dive right into things and assume you have a certain amount of knowledge about the context of what you're doing. They definitely aren't the easiest doc pages to make sense of on the first read. The Textmate docs are probably the best source of information on how Language Grammars and Scope Selectors work. I found it helpful to have the online Ruby regex tester Rubular on hand for testing as well as the Ruby Doc Regex page open as a reference for things like lookaheads, lookbehinds, options, and so on. The patterns use Ruby-style regular expressions syntax. Scope selectors - the scope names (similar to CSS classes) that will be used by your theme style the code in your text editor.Patterns - the rules (regular expressions) that will be used to identify the different parts of your document.Your Language Grammar consists mainly of two key things: Starting from scratch, the structure of the grammar and how things related to one another became a lot clearer and I was able to address several more language patterns that I had initially struggled with. On my second pass, I decided to rebuild the Language Grammar from scratch. My first pass at this was customizing the PHP-Twig bundle to address some additional functionality. There is limited documentation and it takes a good amount of time banging your head against your own theories until things start to make sense. Customize a Theme to style your code to your preferencesīy far, the most challenging thing to get my head around while building out a Textmate Bundle was the Language Grammar.Create a Language Grammar that defines the syntax of your code.Most of what I'll share below has been learned through a process of trial and error and cursing – which I will refrain from in my memorandum.īelow, I'll discuss some highlights on how to: ![]() ![]() I have no special knowledge on this topic. First, as simply a reference for myself, and second, hopefully, as a resource that others can refer to if they'd like to help maintain, customize, or contribute to a Language Grammar or Theme that is valuable to their workflow. My treatment of these topics will not be comprehensive this post is my attempt to document some of those things I learned along the way. Rebuilding the bundle helped me get a better understanding of how to create a Language Grammar, how a Language Grammar and a Theme are related to one another, and gave me a fair bit of practice writing regular expressions (an arcane skill that mysteriously brings me joy).ĭocumentation on Language Grammars remains a bit elusive and, while some references on theming are a bit less scarce, I've found it plenty difficult to get up to speed on the topic and feel confident about what I was doing. On top of this, I wanted to customize a theme to my preferences and struggled to get the themes I had working with the grammar in a way that made me happy.Īfter a few attempts to customize the PHP-Twig bundle, I ended up using it mostly as a reference and re-building the Craft-Twig fork of the bundle from scratch. Certain keywords were not recognized or highlighted incorrectly and a number of handy tab shortcuts and key bindings were not available. There was an existing PHP-Twig Textmate bundle which was a good starting point but there were several Craft-specific improvements I wanted to make. Over the past couple of years I've been working a lot with Craft CMS and Twig. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |