I'm using XDocReport to generate pdf file from docx word template.
In my template I have following:
Name <<${data.name}>>
<<[#if data.nickname??]>>Nickname <<${data.nickname}>><<[/#if]>>
Surname <<${data.surname}>>
The problem is when there is no nickname, then I have extra empty line between Name and Surname.
Is there a way I can avoid this?
I would like to have nickname displayed between if it is given.
Otherwise I would like to display Name following directly with Surname without the extra line.
How can I do this?
If you put the if tags into their own lines, the horizontal whitespace around them and the linebreak after them is ignored:
Name ${data.name}
[#if data.nickname??]
Nickname ${data.nickname}
[/#if]
Surname ${data.surname}
Related
I'm looking for a macro in asciidoc to fill some dot for answering a question in an exam, for example.
Firstname ................
Latex has something called \fillin or \dotfill , I'm looking for the same thing.
I use asciidoctor-pdf to render my asciidoc.
As far as I know, there's no built-in feature in Asciidoctor but you can write a block extension:
[form]
First name
Last name
Age
The extension will compute how many dots is needed to fill each line and create a paragraph with the result.
When using an HTML backend, the result might look like:
<p>
First name .....<br/>
Last name ......<br/>
Age ............<br/>
</p>
You could also add an option to configure the character used to fill the line:
[form,fill=_]
In this case it would produce:
<p>
First name _____<br/>
Last name ______<br/>
Age ____________<br/>
</p>
If you've never written an Asciidoctor extension before, you can have a look at: https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/9efe18673cf5eca79f4121755e043effeddd7cd3/lib/shout-block/extension.rb
I have a delimited file that is delimited by semi colon.
The first row in this file is the header, and the header tokens are in double quotes: an example is below:
"name", "telephone", "age", "address", "y"
When using the tFileDelimited and tMap and you pull the fields in, they look like this with underscores around the fields:
_name_, _telephone_, _age_, _address_, Column05
SO it seems that the fields, the double quote is changed to underscore character and for some reason the last field is a single character without the quotes, but Talend seems to ignore this field name and gives its own default.
Just wondering if anyone has encountered this kind of behaviour and whether one should use a regex to remove the double quotes, to preprocess this first.
Any help appreciated.
Be sure to remove extra blank spaces in the first row, between header tokens. If you use Metadata to import your file, you should have the right names appearing, (just check the options : 'heading rows as column names' and "\"" as the text enclosure)
I have code like this :
FTL:
<#compress>
${doc["root/uniqCode"]}
</#compress>
Input is XML Nodemodel
The xml element is having data like: ID_234 567_89
When it is processed the out is: "ID_234 567_89"
The three white spaces between 234 and 567 is trimmed down to one white-space and lost all the white spaces at the end of the value.
I need the value as it is :"ID_234 567_89 "
When i removed the tags it works as expected irrespective of newFactory.setIgnoringElementContentWhitespace(true).
Why should tag trims data resulted from ${}?
Please help.
You could simply replace the characters you don't want manually (in the following example tabs, carriage returns and newlines), e.g.
${doc["root/uniqCode"]?replace("[\\t\\r\\n]", "", "rm")}
See ?replace built-in for strings: http://freemarker.org/docs/ref_builtins_string.html#ref_builtin_replace
The string is very long and contains first names, last names, many spaces and emails. Sometimes names are missing. I'm trying to extract all the emails into an array with a Ruby script. How would I accomplish that?
I found this as the best regex:
^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$
My string looks something like:
"first name last name abc#hotmail.com firstname def#gmail.com"
How do I create a function that loops through the string and pushes emails into an array?
An email could not have space, so you could use the regex /\S+#\S+/:
irb(main):004:0> "first name last name abc#hotmail.com firstname def#gmail.com".scan(/\S+#\S+/)
=> ["abc#hotmail.com", "def#gmail.com"]
\S matches the non blank char.
OK, I am giving this a shot. There are a gazillion SO questions with answers for my question but none that solve my issue.
I am creating a rake task to parse a flat text file in RoR. The file has a header but there are not any delimiters other than blank space. So I was going to use the blank space as delimiter but it will not work. Here is example of text file:
Name Birthdate
Bill 12/25/86
John Smith 1/1/87
If i use ' ' as a delimiter than I get the correct result for the first entry but not the second as there are 2 strings before the date and not just one. Here is how I have been trying to do this:
File.open(file, "r").each do |line|
name, birthdate = line.strip.split("")
user = User.new(user_name: name, birth_date: birthdate)
user.save
end
I cannot figure out how to deal with the fact that the first "field" may or may not be a single word. Ultimately I would prefer to require csv and then my issue would not exist.
Thanks in advance.
You probably want to change the format if possible but working with your two examples you could do something like this
components = line.split(' ')
date = components.pop
name = components.join(' ')