# Question about the Template type in the PkgTemplates.jl package

**URL:** <https://discourse.julialang.org/t/question-about-the-template-type-in-the-pkgtemplates-jl-package/52545>\
**Category:** General Usage\
**Tags:** question, package, pkgtemplates\
**Created:** [December 28, 2020, 10:27pm UTC](https://discourse.julialang.org/t/question-about-the-template-type-in-the-pkgtemplates-jl-package/52545 "2020-12-28T22:27:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![florian](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@florian](https://discourse.julialang.org/u/florian)\
**Post date:** [December 28, 2020, 10:27pm UTC](https://discourse.julialang.org/t/question-about-the-template-type-in-the-pkgtemplates-jl-package/52545/1 "2020-12-28T22:27:14Z")

</div>

Hi everyone, I have a question regarding Types/Functions that came up after I discovered the PkgTemplates.jl package.

In this package I can define an object of type Template like so:

> t = Template();

Then, to actually create the template, I do:

> t(“PkgName”);

And I cannot understand why I can call t, which is a Type, like it is a function? I looked at the source Code, and the (I think) relevant part is this:

> “”"  
> (::Template)(pkg::AbstractString)  
> Generate a package named `pkg` from a `Template`.  
> “”"  
> function (t::Template)(pkg::AbstractString)  
> …  
> …  
> …  
> end

Can someone explain to me what this construct does? Does it convert any Template Type into a function of the same name? I looked at the documentation for functions and types but I can’t figure it out. Why not just create a function like

`createtemplate(t::Template) = ...`?

Thanks in advance for any explainations!

---

<div class="post-metadata">

**Author:** ![dilumaluthge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dilumaluthge/32/29283_2.png) [@dilumaluthge](https://discourse.julialang.org/u/dilumaluthge)\
**Post date:** [December 28, 2020, 10:33pm UTC](https://discourse.julialang.org/t/question-about-the-template-type-in-the-pkgtemplates-jl-package/52545/2 "2020-12-28T22:33:57Z")

</div>

FWIW you can also do this:

```julia
t = Template()

generate(t, "MyPackageName")

```

Anyway, the usage `t("MyPackageName")` is called a “function-like object” or “callable object”. Docs: [Methods · The Julia Language](https://docs.julialang.org/en/v1/manual/methods/#Function-like-objects)

---

<div class="post-metadata">

**Author:** ![florian](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@florian](https://discourse.julialang.org/u/florian)\
**Post date:** [December 28, 2020, 10:39pm UTC](https://discourse.julialang.org/t/question-about-the-template-type-in-the-pkgtemplates-jl-package/52545/3 "2020-12-28T22:39:03Z")

</div>

Thanks a lot for clarifying, and pointing me to the right part of the documentation!
