The attached patch extends Drupal.settings with the paths of all installed libraries. To get the path of the codemirror library for example, use:

Drupal.settings.libraries['codemirrorPath']
CommentFileSizeAuthor
libraries-js-settings.patch540 bytesdavidtrainer
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler’s picture

Status: Needs review » Needs work
+++ b/libraries.module
@@ -6,6 +6,18 @@
+  foreach($libraries as $library=>$path) {

This should be:
foreach ($libraries as $library => $path) {
to abide by Drupal coding standards

+++ b/libraries.module
@@ -6,6 +6,18 @@
+    drupal_add_js(array('libraries' => array($library . 'Path' => $path)), 'setting');

I don't really like that string concatenation. I would like it better, if you could access the paths as Drupal.settings.libraries[paths][codemirror] or something like that.

Most importantly, though, what is the use-case for this?
In the 7.x-2.x branch we have a lot more information on the libraries than their path, and we definitely don't want store all of that information in JavaScript, so I would really like to know what you are doing with this information.

sun’s picture

Status: Needs work » Closed (won't fix)

I don't think we want to do this. There's no point to have the path to the PHPMailer library in Drupal.settings.