[Bps-public-commit] rt-extension-formtools branch variables-in-html created. 1.01-2-gcd09584
BPS Git Server
git at git.bestpractical.com
Tue Jan 16 19:31:12 UTC 2024
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-formtools".
The branch, variables-in-html has been created
at cd09584d1f9f10ed4d97b8a3c41eee6021030620 (commit)
- Log -----------------------------------------------------------------
commit cd09584d1f9f10ed4d97b8a3c41eee6021030620
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jan 16 14:29:14 2024 -0500
Support to embed ticket variables to raw html
With this, admins will be able to add ticket links on result page, e.g.
<a href="/Ticket/Display.html?id={$TicketId}">{$TicketSubject}</a>
diff --git a/html/Forms/dhandler b/html/Forms/dhandler
index b88ee50..674929d 100644
--- a/html/Forms/dhandler
+++ b/html/Forms/dhandler
@@ -12,7 +12,7 @@
my $button_label = loc('Next');
foreach my $element ( @{$form_config->{'formtools-pages'}{$page}{'content'}} ) {
if ( $element->{type} eq 'raw_html' ) {
- $m->out( $element->{html} );
+ $m->out( RT::Extension::FormTools->_ParseContent( TicketObj => $ticket_obj, Content => $element->{html} ) );
}
elsif ( $element->{type} eq 'hidden' ) {
$m->out('<input type="hidden" class="hidden" name="' . $element->{'input-name'}
diff --git a/lib/RT/Extension/FormTools.pm b/lib/RT/Extension/FormTools.pm
index ac06a37..8ad805c 100644
--- a/lib/RT/Extension/FormTools.pm
+++ b/lib/RT/Extension/FormTools.pm
@@ -49,6 +49,21 @@ sub _GeneratePageId {
return substr( sha1_hex( time . int rand 10000 ), 0, 8 );
}
+sub _ParseContent {
+ shift if ( $_[0] // '' ) eq __PACKAGE__;
+ my %args = (
+ Content => undef,
+ TicketObj => undef,
+ @_,
+ );
+ return $args{Content} unless $args{TicketObj} && $args{Content} && $args{Content} =~ /\{\s*\$\w+\s*\}/;
+ require RT::Template;
+ return RT::Template->_ParseContentSimple(
+ TemplateArgs => { Ticket => $args{TicketObj} },
+ Content => $args{Content},
+ );
+}
+
{
package RT::Attribute;
no warnings 'redefine';
-----------------------------------------------------------------------
hooks/post-receive
--
rt-extension-formtools
More information about the Bps-public-commit
mailing list