·

regexp

Regexes for quickly mocking stuff

This is a small collection of regular expressions to find pieces of code and replace them with PHPUnit mocks. It’s useful for copy/pasting existing pieces of code (a constructor signature for example) and transforming them into usefull code for mocking in PHPUnit, without having to type everything out. Disclaimer: some small code formatting might be read further ...

Programatically prefix the img src attribute with a domain name

I just wanted to share this with you guys, because otherwise I might forget it: This is a simple method to prefix the src -attribute of an img -tag with a specific domain name. This method takes HTML like: And prefixes it like this: This is ideal for when you got HTML from WYSIWYG-editors for read further ...

Split content with a horizontal rule

Today I want to share a little technique with you that I use for much of my clients. There are many times when you need the content to be split in two in the frontend. Think about a custom wrapped header, a text in 2 columns, an introduction, etc. In my opinion the client must read further ...

Replace a XSL parameter in PhpStorm to a choose with a default value

Just a small something I wanted to share: When you want to convert a XSL parameter in PhpStorm to a choose with a default parameter, you can do so with a simple regexp. Say you’ve got something like this: And you want to convert it to something like this: Then just find and read further ...