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

Feature request: comment syntax #21

Open
dahlia opened this issue Mar 9, 2018 · 14 comments
Open

Feature request: comment syntax #21

dahlia opened this issue Mar 9, 2018 · 14 comments
Assignees

Comments

@dahlia
Copy link

dahlia commented Mar 9, 2018

Sometimes we need to explain the intention of a templating code. Comments can be useful for such situations. Though I have no idea how the comment syntax should look like.

@arowM
Copy link
Owner

arowM commented Mar 10, 2018

Thanks for an issue.

Heterocephalus is supposed to be used with another template engine.
So, we can use comment syntax of the other template engine.

For example, if we are using pug, we can inject any comment as follows.

.someBlock
  | %{forall paragraph <- lines paragraphs}
  p.someBlock_paragraph
    // This is comment syntax for pug
    | \#{ paragraph }
  | %{endforall}

Even with a raw HTML, we can use comment like bellow example.

<div class="someBlock">
    %{forall paragraph <- lines paragraphs}
    <p class="someBlock_paragraph">
        <!-- This is comment syntax for html -->
        \#{ paragraph }
    </p>
    %{endforall}
</div>

Is this work for your intention?

@dahlia
Copy link
Author

dahlia commented Mar 10, 2018 via email

@chreekat
Copy link

chreekat commented Mar 10, 2018 via email

@arowM
Copy link
Owner

arowM commented Mar 11, 2018

@dahlia Thanks. It makes sense!
Then how about this work around?

<div class="someBlock">
    %{forall paragraph <- lines paragraphs}
    <p class="someBlock_paragraph">
        \#{ comment "This is a comment." }
        \#{ paragraph }
    </p>
    %{endforall}
</div>
comment :: String -> String
comment = const ""

@arowM
Copy link
Owner

arowM commented Mar 11, 2018

@chreekat Thanks for helpful information.

I do not want to introduce new syntaxes by the reason of just convenience because it is easy to add new feature but it is difficult to remove it after released it.
To tell the truth, I don't know it's worth valuable to introduce comment syntax. Would you be able to lend your expertise?

@chreekat
Copy link

This point would be best made with concrete examples. @dahlia, do you have any to share? I will look to see if I have any, also.

@arowM
Copy link
Owner

arowM commented Jun 11, 2018

Is there any opinions, @dahlia ?

@dahlia
Copy link
Author

dahlia commented Jun 12, 2018

Actually I use Heterocephalus for generating Python and JavaScript codes. As they both have their own comments, I currently stick with a workround mentioned above. The problem is that its content is out of scope and merely nonsense for people who read the generated codes.

@arowM
Copy link
Owner

arowM commented Jun 12, 2018

Thanks.
What do you think about this idea using comment function?

@dahlia
Copy link
Author

dahlia commented Jun 12, 2018

Although using a no-op function barely works, since its syntax is quite picky (e.g., need to escape a double quote), I personally am not likely to use that.

@arowM
Copy link
Owner

arowM commented Jun 12, 2018

OK. It makes sense.
The other reason, I think, to introduce special notation is to improve readability.

@dahlia , are you interested in taking a stab at a PR?

@arowM
Copy link
Owner

arowM commented Aug 5, 2018

I meant if you are not interested in creating PR by yourself, I'll do it by myself.
I'll assume this issue is not actually important for you if there are no replies from you in a week from today, @dahlia .

@dahlia
Copy link
Author

dahlia commented Aug 8, 2018

Sorry for the late response. I would appreciate if you're going to add the own comment syntax to Heterocephalus. 😄

@arowM
Copy link
Owner

arowM commented Aug 8, 2018

Thanks for response!
I'll do it.

@arowM arowM self-assigned this Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants