Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:17
    straight-shoota synchronize #10827
  • 06:04
    straight-shoota edited #10677
  • 03:59
    HertzDevil edited #10829
  • 03:58
    HertzDevil labeled #10829
  • 03:58
    HertzDevil opened #10829
  • 00:41
    stakach opened #10828
  • Jun 16 20:51
    straight-shoota synchronize #10827
  • Jun 16 20:28
    straight-shoota edited #10827
  • Jun 16 20:28
    straight-shoota synchronize #10827
  • Jun 16 13:19
    straight-shoota closed #10823
  • Jun 16 09:16
    straight-shoota milestoned #10825
  • Jun 16 08:46
    straight-shoota edited #10827
  • Jun 16 08:45
    straight-shoota labeled #10827
  • Jun 16 08:45
    straight-shoota opened #10827
  • Jun 16 08:45
    straight-shoota labeled #10827
  • Jun 16 08:16
    straight-shoota labeled #10820
  • Jun 16 07:44
    straight-shoota labeled #10824
  • Jun 16 07:44
    straight-shoota synchronize #10825
  • Jun 16 07:43
    straight-shoota milestoned #8777
  • Jun 16 07:43
    straight-shoota edited #8777
Thore Bödecker
@foxxx0
correct
Ali Naqvi
@naqvis
AFAIK crinja does this trick of run-time execution, so that might be something you can refer to
Thore Bödecker
@foxxx0
mh, looks like crinja strictly expects values and not custom classes
maybe i'll need to parse the user-supplied argument then and provide crinja with the correct value? but then there is no point to pulling in crinja
Ali Naqvi
@naqvis
hmm, how come such conclusion?
Template engine doesn't force you to any specific set of usage
you can access any object as long as template engine has access to that object
For example
{%- for article in articles if article.published %}
  <div class="article">
    <h2><a href="{{ article.href|e }}">{{ article.title|e }}</a></h2>
    <p class="meta">written by <a href="{{ article.user.href|e
      }}">{{ article.user.username|e }}</a> on {{ article.pub_date|dateformat }}</p>
    <div class="text">{{ article.body }}</div>
  </div>
{%- endfor %}
Steve Hiemstra
@speg
speaking of templates, how do i make this work:
ECR.def_to_s "#{ECR_ROOT}/greeter.ecr"
Can't do that when calling a macro?
George Dietrich
@Blacksmoke16
does that not already work?
Steve Hiemstra
@speg

Kinda. I think it's constant above that is broken:

require "ecr"

ECR_ROOT = "./src/template/components/ecr"

class Greeter
  def initialize(@name : String)
  end

  ECR.def_to_s "#{ECR_ROOT}/greeter.ecr"
end

pp! ECR_ROOT
pp! Greeter.new("John").to_s # => "Greetings, John!\n"

Gives:

There was a problem expanding macro 'embed'

Code in macro 'def_to_s'

 2 | ECR.embed "#{ECR_ROOT}/greeter.ecr", "__io__"
     ^
Called macro defined in /usr/local/Cellar/crystal/1.0.0/src/ecr/macros.cr:69:3

 69 | macro embed(filename, io_name)

Which expanded to:

 > 1 | {{ run("ecr/process", "#{ECR_ROOT}/greeter.ecr", "__io__") }}
          ^--
Error: Error executing run (exit code: 1): ecr/process '"./src/template/components/ecr"/greeter.ecr' __io__


stderr:

    Error opening file with mode 'r': '\"./src/template/components/ecr\"/greeter.ecr': No such file or directory
George Dietrich
@Blacksmoke16
try and use __DIR__ instead of .
pretty sure . is the dir you're executing the file from while __DIR__ is the location of the file or something like that
oh but try doing ECR.def_to_s "#{ECR_ROOT.id}/greeter.ecr"
Steve Hiemstra
@speg
same thing, I had also tried using Dir.current with no luck
ooh, .id?
George Dietrich
@Blacksmoke16
yea
Steve Hiemstra
@speg
Success! 🙌🏼 Thank you sir. I haven't used macros yet, what's going on here?
George Dietrich
@Blacksmoke16
seems like its interpolating the string literal into the other string. Notice the path in the error has like \", instead of just like ecr/greeter.ecr
.id returns the raw value of the constant, e.g. ./src/template/components/ecr
maybe thats a bug as it's deff not what you'd expect :shrug:
Steve Hiemstra
@speg
hehe, neat. I was reading up on macros just last night but obvs need to learn some more. Thanks again!
didactic-drunk
@didactic-drunk
Why does crystal doc skip all my classes except for a monkey patched Slice in my project
George Dietrich
@Blacksmoke16
I'd guessCrypto already exists and is nodoc
didactic-drunk
@didactic-drunk
I don't see defined Cryptoanywhere. It's implicitly defined as Crypto::{Subtle,Bcrypt,Blowfish}
oprypin
@oprypin:matrix.org
[m]
@didactic-drunk: because Crypto is marked as originating from stdlib by its first occurrence in the whole code blob, and the whole stdlib is excluded from doc building
didactic-drunk
@didactic-drunk
@oprypin:matrix.org Now I have a workaround. Thank you
oprypin
@oprypin:matrix.org
[m]
@didactic-drunk: im scared. what is it?
didactic-drunk
@didactic-drunk
From IRC (bridge bot)
@FromIRC
<oprypin> oh.
oprypin
@oprypin:matrix.org
[m]
wow what a nice deduction just from that hint
didactic-drunk
@didactic-drunk
:curtsey:
me
@me:ky.rs
[m]
@didactic-drunk I appreciate your explanation on what is not a secret, Lol.
Jonathan Silverman
@mixflame
please vote for my PR guys <3 amberframework/amber#1265
if you use amber
<3
didactic-drunk
@didactic-drunk
@me:ky.rs You'll probably like Bidet (Who doesn't? They're hours of fun)
1 reply
postmodern
@postmodern:matrix.org
[m]
@didactic-drunk: do you wnat me to move ioctl.cr to crystal-posix? if so, could you look over the code first.
didactic-drunk
@didactic-drunk
@postmodern:matrix.org You're welcome to move it now, or not. I'll have to look in a few hours but that can be handled with PR's.
How do I check if a module exists in a macro?
Kaia Leahy
@tenebrousedge
why?
usually if I am wondering about questions of that nature, I'm checking if an object subclasses a type, or whether it responds to a given method
didactic-drunk
@didactic-drunk
I have an optional module which may not exist if not required
Jonathan Silverman
@mixflame
there is a definite bug in resolving localhost sometimes in crystal on my OS
resulting in my crystal app starting sometimes in crashed states
Nolan Mayersky
@nolyoi
I'm trying to install crystal from source and getting a You need to have a crystal executable in your path! or set CRYSTAL env variable. I've tried CRYSTAL="$HOME/crystal/bin/crystal" and
export PATH="$HOME/crystal/bin/crystal:$PATH". Anyone know what I'm missing here?
Ali Naqvi
@naqvis
you need to have previous version of Crystal to compile newer version
Nolan Mayersky
@nolyoi
theres no way to build from source for unsupported linux distros?
figured it out. had to download the tarball and use that crystal binary to run make in the source
jhass
@jhass:m.aeshna.de
[m]
there's https://github.com/crystal-lang/bootstrap-script if you wouldn't trust that approach, but probably needs some patching up by now (and a lot of patience)