get the jquery mobile version

Today I needed to know which JQM version is available in a certain context. Maybe I wasn’t clever enough to use the right search terms. Howsoever, it took far to long to google the answer.

console.log("JQM version: " + $.mobile.version);

Okay, I could have guessed that one. 😉

restrict http methods on routes in drupal 8

Good sources for quick overview:

Definition of routes happens in yourmodule.config.yml. The structure of a route definition is documented on d.o., but documentation is incomplete.

Especially I couldn’t find any useful documentaction on how to restrict the route definition to a specific method (in my case GET). The symfony way of using methods: [GET] doesn’t work. Seems that drupal is using a depreciated way of defining the allowed methods. Symfony’s route.php on github (see setMethods)

The solution as today is to put an _method definition under the requirements section in the yaml file:

requirements:
_method: 'GET'

Note that you have to use a string, even in case of more than one method. Example: ‘GET|POST’.

Change record on d.o. on upgrading to symfony 3.0 in a subsequent minor release.
See also the upgrade notes from the symonfy team at github. According to these docs, the structure of the routing definitcccion will likely change soon.

To setup other HTTP Methods than GET and POST for your route, you can use symfony’s fake method parameter in the query string. I didn’t test if this actually works on a D8 installation yet.