Skip to content

Smarter Templates #2

@atomicptr

Description

@atomicptr

In theory it would be cool if we could infer some properties about the project automatically to offer them as variables in the template

for instance given the following PHP project (this is similar in Clojure, Java, etc)

|-- composer.json
|-- src/
|---- App.php
|---- Models/
|-------- Post.php

we can have the root namespace set to MyCompany\\MyProject\\" at src`` in the composer.json

if we now do:

$ tmplr src/Models/Tag.php

we could theoretically infer from a) the file ending (.php) that this is presumably a .php project and therefore parse the composer.json for the root namespace and offer the full namespace in the template

<?php

namespace {{.php.namespace}};

class {{.name}} {
}

This might be a cool feature, although people would have to implement the language features they care about themselves

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions