I am working on a theme for a client, and have run into an instance where I would like to add to
Drupal.settings via drupal_add_js() from the theme.
In this particular case, it is really most appropriate to do it from the theme itself and not a module hook, as the setting is related to the theme itself.
Doing it from template_preprocess(), or one of its relatives, is too late because
$vars["scripts"] has already been built. I suppose I could do something like the following code, but this doesn't seem right.
$settings = array( "bar" => "bar", ); drupal_add_js(array("foo" => $settings), "setting"); $vars["scripts"] = drupal_get_js();
Is doing it from hook_theme() really the only option, or is the above approach kosher?