Giter Site home page Giter Site logo

Template options about topcoder-greed HOT 10 CLOSED

vexorian avatar vexorian commented on September 23, 2024
Template options

from topcoder-greed.

Comments (10)

zen0wu avatar zen0wu commented on September 23, 2024

This is actually a pretty awesome idea!
Definitely gonna have this!

The type should be a string array I guess, according to the current use case.
Do you think this is enough?
Maybe we need

  options {
    multiprocess = true
    timeout = 3 seconds
  }

But this will make things more complicated, and I'm not even sure if the template can support things like 3 seconds in the if statement. Likely not. :-|

from topcoder-greed.

vexorian avatar vexorian commented on September 23, 2024

That's enough. Of course a more flexible syntax would be better but I know that's hard and we need to avoid making things too complicated.

You can do ${if ssss = 3}, but it doesn't work with many variables. It is very odd that it randomly works or not.

Of course, in that idea , it would be better if you defined things that are not just for ${if, but also for printing in the template. If you could print ${options.timeout}, that would be cool. But so far if only the boolean flags thing is possible, that's good.

from topcoder-greed.

vexorian avatar vexorian commented on September 23, 2024

Of course, for setting theme options maybe something like:

options {
    backgroundColor = #eee 
    forrgroundColor = #111 
}

Would be nice, but it does get more complicated.

from topcoder-greed.

vexorian avatar vexorian commented on September 23, 2024

No, that would be a bad idea, but maybe if we could use:

problemdesc {
options {
     styleSheet = 'somecustompath.css'
}
}

So that coder could use own style sheet it would be cool.

from topcoder-greed.

vexorian avatar vexorian commented on September 23, 2024

About the syntax (and if we agree with it, I can try implementing it as it is a wonderful unbusy time I am having). There are two things I think would be wonderful to be able to have.

  • Boolean conditions (So that we can do ${if}, ${else}.
  • String fields. I didn't think of this at first, but I think it would be very important to be able to determine what to type in some parts of template.

I think the answer to do this both is something like this:

  • A part related to template definition declares the variables it has available.
  • Initially, all variables are initialized with null.
  • default.conf possibly shouldn't set any of the variables that are meant to be used with ${if} (leave them as null). This way, if someone's config file doesn't set them, they are null too, but this someone can set them to non-null.

If we could do string comparisons inside ${if} it would be easier, but I tried and jmte doesn't seem to like them.

@wookayin : More opinions would be good.

from topcoder-greed.

zen0wu avatar zen0wu commented on September 23, 2024

In my opinion, a options map from string to string is enough. For example,

options {
  multiprocess = true
  theme = dark
}

If jmte can recognize ${if options.multiprocess} iff it has a non-null value, any value is fine.
In this way, the string->(boolean | string) map is expressive enough, I think.

from topcoder-greed.

vexorian avatar vexorian commented on September 23, 2024

If default.conf has:

options {
    multiprocess = true
}

And greed.conf has:

options {
      theme = dark
}

Will options.multiprocess still be "true"?

from topcoder-greed.

zen0wu avatar zen0wu commented on September 23, 2024

Yes, that's a problem.
But according to jmte doc, user can set it to false, and it will be false.
When evaluating if condition, it checks if it's null or toString resulting in false.

http://jmte.googlecode.com/svn/trunk/doc/index.html

from topcoder-greed.

vexorian avatar vexorian commented on September 23, 2024

Yes, that's a problem.

Do you mean that options.multiprocess will be "true" ? That's actually very good.

from topcoder-greed.

zen0wu avatar zen0wu commented on September 23, 2024

Oh, I misunderstood you.
Yes, in your situation it will be true.
I thought you meant user may not able to disable the multiprocess, so I looked up the doc of jmte and it turns out the user can disable it by setting the value to false.

from topcoder-greed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.