Guest User

Untitled

a guest
Oct 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #!/usr/bin/perl
  2. package Test;
  3. use Moose;
  4.  
  5. sub get_template {
  6. my $template =<<'END_TEMPLATE';
  7. [%- USE assert -%]
  8. <kayako_staffapi>
  9. <create staffapiid="[%- staffapiid -%]">
  10.  
  11. <!-- Begin Creator Properties -->
  12. <fullname>[%- user.fullname -%]</fullname>
  13. <email>[%- user.assert.email -%]</email>
  14. <creator>staff</creator>
  15. <userid>0</userid>
  16. <staffid>[%- user.id -%]</staffid>
  17.  
  18. <!-- Begin Ticket Properties -->
  19. <subject>[%- ticket.assert.subject -%]</subject>
  20. <departmentid<[%- ticket.assert.departmentid -%]</departmentid>
  21. <ticketstatusid>[%- ticket.statusid -%]</ticketstatusid>
  22. <ticketpriorityid>[%- ticket.priorityid -%]</ticketpriorityid>
  23. <tickettypeid>[%- ticket.typeid -%]</tickettypeid>
  24. <ownerstaffid>[%- ticket.ownerstaffid -%]</ownerstaffid>
  25. <emailqueueid>[%- ticket.emailqueueid -%]</emailqueueid>
  26. </create>
  27. </kayako_staffapi>
  28. END_TEMPLATE
  29. }
  30.  
  31. package main;
  32. use strict;
  33. use warnings;
  34.  
  35. use Template;
  36. use Data::Dumper;
  37.  
  38. my %data = (
  39. staffapiid => "1234",
  40. ticket => {
  41. subject => "test",
  42. departmentid => '1',
  43. statusid => '2',
  44. priorityid => '3',
  45. typeid => '4',
  46. ownerstaffid => '5',
  47. emailqueueid => '6',
  48. },
  49. user => {
  50. id => "1234567",
  51. fullname => "Bob Something",
  52. email => 'foo@bar.com',
  53. },
  54. );
  55.  
  56.  
  57. print Dumper %data;
  58.  
  59. my $cfg = Test->new;
  60. my $tt = Template->new;
  61.  
  62. my $template = $cfg->get_template();
  63.  
  64. print $tt->process(\$template, \%data);
Add Comment
Please, Sign In to add comment