[dokuwiki] Re: Retrieving template from plugin JavaScript

  • From: Tamás Haraszti <haraszti@xxxxxxxxxxxxxxxxxx>
  • To: <dokuwiki@xxxxxxxxxxxxx>
  • Date: Sat, 27 Feb 2021 09:41:14 +0100

Hi,

#This e-mail is a reply to the message of Damien Regad
<dregad@xxxxxxxxxxxx>, sent on Sat, 27 Feb 2021 00:13:15 +0100:

#"
Anyone ?


On 19/02/2021 01.01, Damien Regad wrote:
Greetings,

I need to use the current template in a plugin's script.js, but
AFAIK this information is not readily available.

Can you please better describe what problem you wanted to solve with
this?

My first idea was to use DOKU_TPL and extract the template name
from the path, e.g.

let template = DOKU_TPL.replace(/[\\/]$/, "").split(/[\\/]/).pop();

Then I wondered if it would not be better to export that from
$conf['template'] into JSINFO instead, as documented here
https://www.dokuwiki.org/devel:javascript#jsinfo

Thoughts / advice on the better approach would be appreciated.

Cheers
Damien
  
#end of previous message"

In general, you can place any information about your Doku instance in
the page when rendering in your plugin. But your action plugin part
handling calls from your javascript has access to this information
anyway. So, it is not clear to my why would you like to expose this
detail on the page.

Tamás
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: