[TxMt] Re: TM_DATE , Ruby and Latex Template

Alain Matthes alain.matthes at mac.com
Thu Nov 6 22:27:30 UTC 2008


Le 5 nov. 08 à 23:53, Alain Matthes a écrit :

> Hello
>
> I try to create a latex template
>
> I've no problem with the classic method [ NEW from Template] [Edit
> Templates] but
>  with the other method
>
>  [ why  another method ? Only God knows ..]
>
> describes in the help of the bundle.
>
> I create a file in Application Support  > Latex > Templates but iI
> want to use shell variables
>  like TM_FULLNAME TM_DATE TM_ORGANIZATION_NAME etc ...
>
> I put  %!TEX style = snippet at the beginning of my file and I' ve no
> problem with the variables
>  except with  TM_DATE.
>
> I modify the ruby command "LaTeX Template" . I added inside the next
> line
>
> ENV["TM_DATE"] = `date +%d-%m-%dY`.chomp
>
> but it's not enough. What is wrong with my method?


Hi

Perhaps my english language is not good enough ...

I read some questions and answers on the net but I don't have a solution

I can make this

in the latex template command

#!/usr/bin/ruby

require ENV['TM_SUPPORT_PATH'] + '/lib/osx/plist'
require ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes.rb'
require ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'
require ENV['TM_SUPPORT_PATH'] + '/lib/escape.rb'

ENV['TM_YEAR'] = `date +%Y`.chomp
ENV['TM_DATE'] = `date +%Y-%m-%d`.chomp

DMY=ENV['TM_DATE']
puts(DMY)

etc ..

With a template file like this

%!TEX style = snippet

%  Created by ${TM_FULLNAME} on ${TM_DATE}.
%  Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights  
reserved.
etc ...

I get the date in my file with puts(DMY)  but ${TM_DATE} gives nothing


I don't understand how to define the TM_DATE like a shell variable  
inside a ruby script.

Is it possible ?

Best Regards

Alain


More information about the textmate mailing list