Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a content function #178

Open
solleer opened this issue Dec 13, 2017 · 4 comments
Open

Create a content function #178

solleer opened this issue Dec 13, 2017 · 4 comments

Comments

@solleer
Copy link
Collaborator

solleer commented Dec 13, 2017

@TomBZombie I saw your recent amendment to the wiki and was wondering if we will add the content function you use in the example.

@TRPB
Copy link
Member

TRPB commented Dec 13, 2017

Yes, that was going to be my next addition but I was also thinking about other ways we could handle the if statement.

The alternative would be attributes:

<div visible="data(foo)=bar">

But I don't think that's quite so clear.

Or content-mode: unwrap which replaces the elements with its contents, but again, I don't think it's very clear.

In this example, we'd also need to support if/else which again poses a slight issue:

<if data="loggedin" equals="true">
    <then>
         You are logged in
     </then>
    <else>
      Sorry, you must log in to view this page
    </else>
</if>

But we could make the content() function take a selector:

if[equals][data(attr(data))=attr(value)] { content: content('then'); }
if[equals][data(attr(data))!=attr(value)] { content: content('else'); }

it would be up to the individual implementer to decide on the the exact syntax but this would open up some possibilities.

@garrettw
Copy link
Contributor

This whole if/else bit makes me wonder if Transphporm is planning to depart from its original vision of having no code in templates.

@TRPB
Copy link
Member

TRPB commented Dec 13, 2017

This whole if/else bit makes me wonder if Transphporm is planning to depart from its original vision of having no code in templates.

Absolutely, the point I wanted to make is that you can design your own traditional template engine using transphporm as a backend. At the moment Transphporm can already do 95% of it so adding a couple of extra features to nudge it up to 100% isn't really a lot of effort.

Really, it's just a way to show off some of the features of the language in a way that people coming from smarty/twig/whatever will easily grasp

edit: But in light of your comment, I will add that caveat to the wiki page to make it clear that this isn't encouraged!

@TRPB
Copy link
Member

TRPB commented Dec 13, 2017

weirdly that entire wiki page is vanished for me and i can't even view the revision history

edit (again!) nevermind, the link in the nav was wrong, I've corrected it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants